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:
- 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.
- 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 ).
- 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).
https://api.smartthings.com/invitation-web/accept?id=cc2197b9-2dce-4d88-b6a1-2d198a0dfdef
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.