Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Powerwall 2 Gateway API Documentation

This site may earn commission on affiliate links.
If you want the Gateway to have a static IP address, the easiest way is to configure the DHCP server on your router to hand it the same address each time. On my Asus router, this is under Advanced Settings->LAN->DHCP server, but I run a modified firmware so I'm not sure if this is a stock feature.

That's also in the standard ASUS router firmware, just under LAN--> DHCP Server --> "Manually Assigned IP around the DHCP list". It even lets you browse offline hosts it's seen before, so you don't have to memorize the MAC address directly. :)

Now if I could only get my BUG to show up on the LAN regularly... I may need to run an ethernet cable out to the garage to eliminate flakiness.

BUT it looks like the last step is to figure out how to get the python code access to network, so I can have my Diskstation ping my BUG.

Thanks for the help on the wifi!
 
Last edited:
I have tried to get a token based on the GitHub but its errors

HTTP/1.1 301 Moved Permanently

(I have subbed out the password and IP) this is a windows machine

curl -s -i -X POST -H "Content-Type: application/json" -d "{\"username\":\"\",\"password\":\"password12345\",\"force_sm_off\":false}" http://192.168.xxx.xxx/api/login/Basic
HTTP/1.1 301 Moved Permanently
Location: https://192.168.xxx.xxx/api/login/Basic
Date: Sat, 13 Jul 2019 18:54:17 GMT
Content-Length: 0
 
I have tried to get a token based on the GitHub but its errors

HTTP/1.1 301 Moved Permanently

(I have subbed out the password and IP) this is a windows machine

curl -s -i -X POST -H "Content-Type: application/json" -d "{\"username\":\"\",\"password\":\"password12345\",\"force_sm_off\":false}" http://192.168.xxx.xxx/api/login/Basic
HTTP/1.1 301 Moved Permanently
Location: https://192.168.xxx.xxx/api/login/Basic
Date: Sat, 13 Jul 2019 18:54:17 GMT
Content-Length: 0

The solution is in the error :)

You're querying the non SSL endpoint (http) rather than the SSL one (https). Change your target in the curl to https://192.168.xxx.xxx/api/login/Basic. Unless you've added the Powerwall certificate to your local store you'll also have to use the -k option in curl to ignore cert errors as the Powerwall cert is self-signed. I also don't use the -s (silent) option but that's up to you.

curl -i -k -X POST -H "Content-Type: application/json" -d "{\"username\":\"\",\"password\":\"password12345\",\"force_sm_off\":false}" https://192.168.xxx.xxx/api/login/Basic
 
Last edited:
  • Informative
Reactions: NuShrike
The solution is in the error :)

You're querying the non SSL endpoint (http) rather than the SSL one (https). Change your target in the curl to https://192.168.xxx.xxx/api/login/Basic. Unless you've added the Powerwall certificate to your local store you'll also have to use the -k option in curl to ignore cert errors as the Powerwall cert is self-signed. I also don't use the -s (silent) option but that's up to you.

curl -i -k -X POST -H "Content-Type: application/json" -d "{\"username\":\"\",\"password\":\"password12345\",\"force_sm_off\":false}" https://192.168.xxx.xxx/api/login/Basic


welp that didn't give me a error.... gave me nothing went back to prompt.... I can only assume the installer changed the password ger.… I could reset the password but when they come to finish the setup Monday they may get pissed
 
the GitHub says to leave user name empty, my preference would be to get on as 'installer' to see how they have it configured. as 'customer' its kind of not worth anything

The documentation on that site is also about 20 versions behind. It's a great start but not gospel. Without a username I get a 410 - Bad Credentials.

I just ran this command below and it works for me on Windows 10 with curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL. All tokens and passwords <snip>ped.

Note that this is the installer password which since it is randomly generated I've noticed that sometimes it contains characters that need to be URL or command line escaped.
To fix this I simply generated new passwords until I got one with no special characters. You may want to do the same as I'm guessing there is probably an & or something in there.

curl -i -k -X POST -H "Content-Type: application/json" -d "{\"username\":\"installer\",\"password\":\"<password>\",\"force_sm_off\":false}" https://<ip>/api/login/Basic

HTTP/1.1 200 OK
Set-Cookie: AuthCookie=<snip>==; Path=/
Set-Cookie: UserRecord=<snip>=; Path=/
Date: Sat, 13 Jul 2019 23:02:38 GMT
Content-Length: 200
Content-Type: text/plain; charset=utf-8


{"email":"","firstname":"Tesla","lastname":"Energy","roles":["Provider_Engineer"],"token":"<snip>","provider":"Basic"}
 
  • Informative
Reactions: NuShrike
Thank you. Is thier newer documentation?

Not that I'm aware of. The beauty of GitHub is that like Wikipedia you can contribute. I'll make some of these changes.

One thing to make note of is that if you sign in as Installer your Powerwall will go offline. You'll need to start it again to connect it to Tesla for your app data.
 
Ya it's ac disconnected right now well they wait for this 'part' I have no clue what the part is to communicate with the ats genset

I'm really think they reset the password so this may have to wait till after they commision everything


Going to poke some more
 
sweet... got a customer key, the comands still where not working due to a self signed cert added -k and even with a customer key i am getting stuff that the UI would not show me

X:\>curl --header "Authorization: Bearer nonofyourbiz==" -k https://192.168.xxx.xxx/api/solars
[{"brand":"SolarEdge Technologies","model":"SE10000H","power_rating_watts":10000,"server_count":0}]

and as i suspected..... generator not setup

X:\>curl --header "Authorization: Bearer nonofyourbiz==" -k https://192.168.xxx.xxx/api/generators
{"disconnect_type":"None","generators":[]}

so ya guess ill need to have a talk with him
 
Yup new command line works. If I use customer and the password I setup I get a token.if I use installer with S and serial number I get 401 so they changed it. That is super annoying

The installer password is randomly generated on setup so if it was already configured the serial number will not work as the installer password. You can however re-generate the installer password with the serial number. I understand you may not want to do that if the installer needs it.
 
ahe so on his first setup he may have had to write down something random and he will then use it again Monday when he is here ?

ya ill just ask him about the add generator button or ask him to do the wizard again. and if he doesn't i guess ill have to call tesla support and talk to them about it and see what needs to be done

my thinking is that if you configure it with ATS (looks to be a option) that if the gateway knows about a ats it does something like the freq shift it does to shut down the invertors it may do the same thing of maybe a voltage shift of like 108v when the battery gets to low to maintain alive of the inverter or over draw on the 5k per battery it could voltage drop to spin up the ATS/genset untill things normalize on the battery side and then it would go back to 120 or whatever and ats /gens set would go back to sleep


X:\>curl --header "Authorization: Bearer stuff-stuff-stuff==" -k https://ip/api/generators/disconnect_types
["DownstreamATS"]
 
OK, the answer is pretty simple -- my account, even though it was in the administrator group, did not have permission to run certain network commands at root privileges. If I "sudo ping 192.168.2.200" then everything worked fine from the terminal. Who knew that "ping" would be a restricted command!

So...had to log in as Admin, and run the docker image as Admin. It's running now and I'll see if it produces good data.

I'll probably end up running two, one for solar generation and one for consumption, but for now I just want to see solar production.

Thanks all!

If you want the Gateway to have a static IP address, the easiest way is to configure the DHCP server on your router to hand it the same address each time. On my Asus router, this is under Advanced Settings->LAN->DHCP server, but I run a modified firmware so I'm not sure if this is a stock feature.
 
  • Like
Reactions: K3Man
OK, the answer is pretty simple -- my account, even though it was in the administrator group, did not have permission to run certain network commands at root privileges. If I "sudo ping 192.168.2.200" then everything worked fine from the terminal. Who knew that "ping" would be a restricted command!

So...had to log in as Admin, and run the docker image as Admin. It's running now and I'll see if it produces good data.

I'll probably end up running two, one for solar generation and one for consumption, but for now I just want to see solar production.

Thanks all!
Hi, this is the PowerWall API thread you're still posting into.
 
Last edited:
Sorry if I have read through this too quickly and missed something, but all I seem to be able to find are status/read request for the powerwall....does anyone have send/commands figured out yet? I'm mostly looking for the scheduling portion of the wall. I want to create a macro that will allow me to change the scheduling as I have 2 peak times a day in winter.
 
Sorry if I have read through this too quickly and missed something, but all I seem to be able to find are status/read request for the powerwall....does anyone have send/commands figured out yet? I'm mostly looking for the scheduling portion of the wall. I want to create a macro that will allow me to change the scheduling as I have 2 peak times a day in winter.

You want to talk to Tesla's servers, not the Powerwall to do this. The local Powerwall API only has basic ability to control self-consumption modes.

You can actually set a schedule with two peaks if you go directly to the server API to do it. I don't know how much this has been tested, but it appears it's just an app UI restriction that only one peak can be set.

This thread has details on the TOU API: https://teslamotorsclub.com/tmc/threads/tou-api.124729/
 
  • Like
Reactions: Fonzi03
You want to talk to Tesla's servers, not the Powerwall to do this. The local Powerwall API only has basic ability to control self-consumption modes.

You can actually set a schedule with two peaks if you go directly to the server API to do it. I don't know how much this has been tested, but it appears it's just an app UI restriction that only one peak can be set.

This thread has details on the TOU API: https://teslamotorsclub.com/tmc/threads/tou-api.124729/

Awesome thank you I believe that'll have everything I need. Really should be simple to create a schedule. Hopefully with this info and some math I can make a schedule that will charge as needed based off TOU and also if battery is below a certain percentage and the weather is bad so production is not good charge before peak also. It'll take some figuring out but I think I can make it work.