Tesla Powerwall 2 Sensors


I have been playing around with my Tesla Powerwall 2 and Solar install for the last few weeks and managed to get some interesting results using a RESTful sensor against their API which is exposed as:

http://[Tesla Powerwall IP address]/api/meters/aggregates

This provides JSON

To get the latest values I created a number of sensors based on the “instant_power” values for house (load), grid (site), battery and solar. The battery percentage is exposed as JSON at /api/system_status/soe.

Note that my powerwall is on a separate IOT DMZ accessed via an dual homed apache reverse proxy using port 1234

I also created a sensor showing the watts left in the battery based on a 100% capacity of 13.5 kW

Daily aggregate amounts need a value stored from the previous midnight, I used automation to to publish on MQTT the recorded value at midnight and subtracted the current export or imported value for the House, Grid, Solar and Battery.

I have also created a few custom sensors based upon the API - but would be interested on working with someone to develop a complete Powerwall component that incorporates all the logic mentioned into a single component.

Let me know if you’d be interested, I’d be happy to act as a test bed



Sensor definitions



Awesome Work Dave! My powerwall and 16.5 system is getting installed December 12th. Then I will help further this along as best I can! :slight_smile:


Cool, that would be great

Your 15.6kWh system dwarfs my 4.2KWh solar rig here in the UK. My Model S 90D charges at 7kWh here at home and slams the powerwall and/or solar pretty quickly - luckily we get cheap electricity rates after midnight (around 4p/3 cents per kWh)


This is my hack of a custom component sensor for battery percentage


And Solar instant power custom sensor



I’m interested in integrating my powerwall too. It looks like your battery is linked to your wifi. Mine communicates to the Tesla website on a cellular network. Is there any wat to get this information from the Tesla website instead of the battery, or do you know who to turn on the battery wifi and connect it?




I am not aware they open the API like they do for the vehicle. Did you choose cellular for a reason ? Did you gateway not support Ethernet or Wifi ?




I’m guessing that it is just the way they installed it. I wasn’t home at the time and they didn’t have access to connect it to my network. Then again, they must have some cellular deal with Telstra or someone (in Australia) as that’s how it is operating without a sim paid for by me…I did read somewhere that you can connect to the PW2’s network (TEG-XXX), and I can see something like that in range, but I haven’t got the serial number from the cabinet yet to try. There are some details here: https://forums.tesla.com/forum/forums/powerwall-2-api.

I’ll report back if I get it working and, ideally, get the PW to connect to my network instead of connecting to its.



Yes, connect to the TEG AP using the serial number, you also need a username and password to logon to the PW2 via Wifi , the installer may have set their own, luckily mine used their email and the TEG serial number !


Got it connected. Thanks for the help. I connected to the TEG AP and ran the wizard to set it up with my WiFi credentials (instead of the cellular connection it was set up with originally), then restarted it and it started transmitting through my network. Set a permanent URL and now Hassio happily reads the sensors as you listed them at the top of this post.

I was about to try building a component and found that I can’t do that with Hass.io, so I’ll change over to Hasspian. Tinkering is more my thing so Hassio wasn’t really for me anyway, but I’ve a lot to work through before I get there. The custom sensors you wrote above are presumably used when customising Hasspian? Hass.io has just listed the sensor data on my homepage and I can presumably run automations off that. My plan is to turn on the heating if it is mildly cold in the morning, if I have battery left (and turn it on regardless if it is really cold). I can probably do that in either system but I have a few weeks to learn Hasspian before my AC is installed anyway.

Thanks for the help.


glad you got it going, I used the Hassio builds for the components under the config directory - this was a migration from a standalone pi Hass implementation (all in one build)

I am looking at getting the hot water from solar rather than gas when the battery is topped up and I start exporting to the grid - I am using Node Red for those routines



Hi Dave,
Glad to see that a start has been made on this!
I had a PV array and PW2 installed last month and really want to optimise how we’re using the power.
I’ve installed a couple of storage heaters and networked them on Smartlife plugs, and have a wifi switch on order for the immersion heater.
Now what I want to do is automate the control of these components, based on the PW parameters.
I just set up a Raspberry Pi with Hass.io, and am right at the very beginning with all this. In other words, I’m not sure if I can be much help to you, but I am very willing to do what I can.

I found a couple of repos on Github with potentially useful info:



Well, I see I have some way to go here!

I believe I can use IFTTT to operate the switches for the heaters in response to webhooks. I don’t yet understand how I can implement the sensors Dave has described here in order to trigger the webhooks, based on what’s happening with the Powerwall.

Here’s the sort of thing I have in mind:

When the PW is >80% charged and >1kW is going into the battery, then switch on Heater1.
If >0.3kW is going out of the battery and the PW is <90% charged, switch off Heater1.
When the PW is >90% charged and >1kW is going into the battery, then switch on Heater2.
If >0.3kW is going out of the battery and the PW is <95% charged, switch off Heater2.

Can anyone give me a shove in the right direction?


I tried IFTT but it was too slow, so I now use Node Red for logic flows - this is an example where the PW is putting power back into the grid (typically at 100%) so I switch on the electric hot water to use the excess power - it uses zwave to switch on my electric hot water heater and switches it off after 20 minutes

It works great - lots of solar generated hot water on sunny days, no need to revert to mains gas or sell back energy to the grid at a low return

Endpoints are:


The logic is:

Check every 30 seconds, if Site.instant_power < -1000w and load.instant_power < 1000w and Solar.instant_power > 1000w then turn on electric water heater (and tweet a summary of the power state) then start 20 minute timer, then turn it off

Hope this helps


This is a more exotic flow, this checks at pre-determine morning/evening times whether the PW2 has enough battery (set at 50%) for 20 minutes electric hot water, otherwise switches on the gas hot water (using another Zwave unit to controller gas heating/hot water)

Also monitors HA to check whether either gas or electric hot water is switched on and kicks of a 20 minutes timer - this means I can use something external like Alexa to switch on the hot water and always be sure it is switched off after a fixed time


Thanks Dave. That does help.
Where are you running Node Red?

And the code you have described above, is that written in Node Red as well, or into the HA configuration?


I am running Node Red on my Hass.io implementation - the flows are in node red, they read from the PW2 directly and use HASS to control Z-wave devices


So my PW just was installed, but it doesn’t appear to be on my network. The installer’s never asked for my wifi password and its not hardwired with ethernet. Am I out of luck?