Tesla Powerwall II Project (2023)

Ok, so I have connected all of the dots to get Powerwall data from the local gateway into SmartThings and wanted to share how I did it. (It’s not as easy/simple as what Darwin provided for the community, but it seems to be a workable bodge.)

TL:DR; Run pyPowerwall in a docker container on a device on your network that will always be on/available. (Raspberry Pi, NAS, etc.) Then install and set up the TAustin WebRequestor and Counter drivers and make http calls to the pyPowerwall API to get Powerwall status/charge/etc.

I already had a Raspberry Pi on my home network running a VPN server so I did this:

  1. Install Docker (I used directions on Installing Docker on the Raspberry Pi - Pi My Life Up ). I did have to reboot my Pi after installing docker before the hello-world container would run and the docker daemon would start.
  2. Install Portainer in a Docker container (for easier GUI management of your docker containers). (I used directions on Installing Portainer to the Raspberry Pi - Pi My Life Up ).
  3. Install the jasonacox/pypowerwall docker container inside portainer.

Fill out the environmental variables: click on “Env”, then “advanced mode” and paste in and update the key:value pairs for your network (your powerwall gateway password, not your tesla ID password; your email address, your IP address for the gateway)

Click on “Restart policy” and select “Unless stopped”:

Then click on “Deploy the container” button.

At this point, you should be able to test and use a web browser to go to:

http://10.0.x.x:8675/aggregates (where you’ve replaced the IP address with that of the local network device running the pypowerwall docker container) and get a JSON of a bunch of powerwall data. If that doesn’t work, check the logs on the container in Portainer to make sure it’s starting up ok and not having any issues with your environment variables.

If you just go to the ip address:port without the /aggregates, you’ll also get that cool image that shows the real-time power flows in your system.

Now you need to get the TAustin Web Requestor Edge Driver set up to request the data:

You can login on this site with your Smartthings credentials and accept the invitation to the channel, and then make sure you install the Web Requestor, as well as the Counter drivers (and probably the vEdge one if you haven’t, for virtual edge device drivers for more advanced automations, although not exactly required for this basic functionality).
Once the drivers are installed on your hub, it’s time to create a new Web Requestor for each data point that you want to access from the Gateway.

Configure the request #1 in each of the following devices (don’t forget to also change the dashboard setting to show the numeric value):
(update the ip address to match your docker device)
Tesla Powerwall Battery Level
Response key to extract: Percentage
Web Request #1: GET:http://10.0.x.x:8675/soe

Tesla Powerwall Solar
Response key to extract: Solar.instant_power
Web Request #1: GET:http://10.0.x.x:8675/aggregates

Tesla Powerwall Grid
Response key to extract: Site.instant_power
Web Request #1: GET:http://10.0.x.x:8675/aggregates

Battery and Home can also be accessed with battery.instant_power and load.insyant_power if you want to set up two more.

Tesla Powerwall Grid Status
Response key to extract: Grid_status
Web Request #1: GET:http://10.0.x.x:8675/api/system_status/grid_status

If you have an Enphase Envoy gateway, you can also set up a Web Requestor device to extract the solar production from that:

Enphase Envoy Solar
Response key to extract: Production[1].wNow
Web Request #1: GET:http://ip.address.of.envoy/production.json?details=1

Then, create a Counter and start it using the TAustin Counter driver (which you hopefully installed above, but here’s more info on its use: [ST Edge] vEdge Creator: a virtual device generator for end users - #1329 by h0ckeysk8er )

To get the Web Requestor devices to update with the latest values from your gateway, you need to set up a new Routine which will run when the counter gets equal or greater than 5 minutes and it resets the counter back to 0 minutes, and the actions will have each of the web requestor powerwall “devices” to run Pre-configured Web Request #1.

Routine: Tesla Powerwall Refresh Stats 5minutes
If: Tesla Powerwall Counter
main- Duration Equal to or above 5minutes
Then: Tesla Powerwall Counter
main- Reset: push
counter - Reset:push (this will reset the counter back to 0 minutes and it will count up until 5 minutes again and trigger the routine to run again)

Tesla Powerwall Battery Level
Pre-configured web request: Request #1
Tesla Powerwall Grid Status
Pre-configured web request: Request #1
Tesla Powerwall Grid
Pre-configured web request: Request #1
Tesla Powerwall Solar
Pre-configured web request: Request #1
Enphase Envoy (optional)
Pre-configured web request: Request #1

I’ve set up another Routine to remind the family when the Powerwall battery is charged and we are exporting excess energy to the grid, as a good time to run appliances (laundry, dishwasher, etc):

Routine: Tesla Powerwall Charged notification
IF: Any time - Every day - only once per day - use as precondition
When all conditions below are met
Tesla Powerwall Battery level: Extracted key Numeric value: Equal to or above 98
Tesla Powerwall Grid: Extracted key Numeric value: Equal to or below 0 For 1 minute (the grid value is negative when exporting but I don’t think Smartthings handles negative numbers well so you have to just put zero)
THEN: send notification to members: Tesla Powerwall charged and solar producing excess energy. Time to run the dishwasher/laundry/oven!

I have another routine currently that reminds me to change the EV charging speed when the solar production is at least 1000-2000w above our baseline home load and the battery is full. I suspect I’ll be able to find another docker container that allows me to automate that though, to try and minimize non-bypassable charges and use more of my solar during the day to charge the car when it’s home, and ramp down charging when solar production is not enough and I don’t really need to be charging the car.

If you need to automate changes in Reserve percentage or mode on the Powerwall, I think I read that those features would only be available talking to Tesla’s remote API using login tokens, but there is probably already a docker container out there that can do that, and if it has a method to allow GET/POST calls in http (not SSL), you could use these same methods to talk to another container, I think.

Hope this helps someone, and if and when the smarter community members think of more streamlined ways to accomplish this, I hope they will share their improvements.

Update: added notes above to clarify that you’re sending http, not https request to pypowerwall api. Added key:value pairs for battery and Home (load) power, and a reminder to configure the dashboard setting to use the appropriate numerical or text setting so you can see the value at a glance.


Having just experienced a short power outage, I set up a routine to shed loads and turn off devices which aren’t needed when on battery for a grid outage to extend the backup runtime.

Start on the Grid status web request edge device and add a routine, choose “extracted text string” and the powerwall response during outage is “SystemIslandedActive”. (I chose to make it stay present in that mode for 10 minutes before turning off devices so that for short outages, it won’t shed loads.) Add devices to and set their on/off status!

Edit: ugh, got an Enphase envoy update and there’s no unauthenticated local access. You have to get a token and then send it in an authorization:bearer header with a 408 character token and it seems like the current version of the webrequestor can’t handle the long token and session id header requirements and also it requires https without a valid certificate so the Enphase Envoy integration looks like it won’t work without another local device api relay like how the powerwall works now.

Would like this. I have powerwall dashboard running, don’t know if that contains the same components as pypowerwall. But my gateway is configured to read my enphase using a neurio so I can see my enphase data separately from teslas.
Hubitat has a powerwall app/device that communicates directly to TEG, perhaps look into that.

Ip:8675/aggregates works…

I don’t understand the routine. I believe there is a way to program your own routines outside of the gui but I don’t know how.

The good news is these routines can all be setup using the phone app gui if you have added the right edge devices. What are you having difficulty with?

Side note: I updated the tessolarcharge.py script in the pypowerwall tools folder and need to submit a PR to the original developer after a little more testing in the coming week- now it can check the Powerwall charge level and calculate the rate required for charging the Powerwall to 100% by a specified hour in the day and change Tesla EV charging speed to use only the excess solar that isn’t needed for the home AND charging the Powerwall…(the current version doesn’t work well in self-powered mode because the excess solar all goes to the Powerwall and it doesn’t see any going to grid to adjust charging speed and you could end up draining the powerwall with car charging whereas the new update will reduce charging speed if any power starts coming from the grid or powerwall).