[PROJECT] Driver for Connecting to Your Tesla Powerwall

Just installed v1.1.7 of the driver and it looks like it is working! Thank you very much!

I am still checking out the many returned values and validating against my Tesla app. For example, on the app it is currently reporting 5300w of solar production but the driver appears to be reporting 4800w. Your driver is configured to return a lot of values. It is possible that I am not looking at the right value.

I am very grateful that this @snell and @Darwin were able to figure out the proper way to achieve local gateway authentication. Nicely done!!

2 Likes

If you want to shoot me a PM with a Trace log of the results I can try to look into it. Of course they could have "corrections" built into the app that are not part of the raw data.

But no matter what, thanks for letting me know so quickly!

The version is also working for me. Thank you!

I got a good login and some data population with this version too.

The value parsing is a little messed up, it's getting the grid power values and using those for all of grid, battery, solar and house.

I added a log line to get resp.data} in parseAggregates:
{"site":{"last_communication_time":"2021-06-14T15:56:42.090795128-07:00","instant_power":2433,"instant_reactive_power":68,"instant_apparent_power":2433.950081657387,"frequency":0,"energy_exported":854942.014837229,"energy_imported":1581905.2003319096,"instant_average_voltage":204.32137351486261,"instant_total_current":23.927500000000002,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"battery":{"last_communication_time":"2021-06-14T15:56:42.090604139-07:00","instant_power":0,"instant_reactive_power":310,"instant_apparent_power":310,"frequency":60.013000000000005,"energy_exported":867630,"energy_imported":977130,"instant_average_voltage":236.3,"instant_total_current":-0.2,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"load":{"last_communication_time":"2021-06-14T15:56:42.090604139-07:00","instant_power":6165.5,"instant_reactive_power":308,"instant_apparent_power":6173.188337480074,"frequency":0,"energy_exported":0,"energy_imported":3360608.641566163,"instant_average_voltage":204.32137351486261,"instant_total_current":30.17550192589868,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"solar":{"last_communication_time":"2021-06-14T15:56:42.090916622-07:00","instant_power":3742,"instant_reactive_power":-68,"instant_apparent_power":3742.6178004172425,"frequency":0,"energy_exported":2745701.002927059,"energy_imported":2555.54685557616,"instant_average_voltage":203.65453395394857,"instant_total_current":15.3045,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000}}

Do you have the "ChildrenEnabled" preference set? If it is set, it will create a child device for each of the 4 (that I have seen) sets, "site", "solar", "battery", and "load" then put the values it receives to each of those. If the child devices are not enabled everything gets put under the parent device with the Site information taking priority.

1 Like

Yes, and the values published to each child are the same, e.g. right now the Telsa app shows me pulling about 4K from the grid, all childs: battery, load, site, solar all have the same value here:

  • Instant Power : 4103

Well obviously that is not right... I will take a look at it again tonight. The first check just made me think it was a child thing, thus the question.

Ah, typo found:

    if( NumberDevices == 4 ){
        ProcessData( TempData.site, "site" )
        ProcessData( TempData.solar, "solar" )
        ProcessData( TempData.battery, "battery" )
        ProcessData( TempData.load, "load" )

These 4 were all TempData.site

With this change I'm getting matching numbers! (numbers that match the Tesla app)

2 Likes

@tomuo16103: You posted as I was finishing the fix in the code... I noticed it as soon as I went back in. ARG! Copy/paste you wonderful evil thing.

Updated Version(s):

  • TeslaDriver.groovy = 1.1.8

Change(s):

  • Fixed ParseAggregates error that made it so only site was being used for all four.
2 Likes

@snell I just got 3 powerwalls and solar with 2 inverters. If you want any api data let me know. I was looking at GitHub - vloschiavo/powerwall2: Tesla Powerwall 2 - Local Gateway API documentation and found some interesting stuff like api/operation which returns

{"real_mode":"backup","backup_reserve_percent":20}

I'll have to check that when the next hurricane is on the way to see if it changes to storm mode.

I don't have permission to turn on the solar yet, but it looks like the inverters may give data as well.

That site is where I based a lot of information in the driver on, it is in the Thank You(s) section! Great resource.

If you are interested... I can always make a version that walks though pretty much all the possibilities now and returns the results so we can look them over and parse them out to see if anything is useful.

But not right away. I will not be able to work on anything new until after July 6th.

I'm in no huge hurry. If you do make something that crawls the api and dumps all the data, I could get you dumps of different states and settings.

I appreciate that. I will have to make something (or a command at least) soon after I get back.

@snell Thank you for this work, looks great! I ordered my PW2 a few weeks ago and intend to use my Hubitat to load-shed our big old Ducted AC system during power outages (it's controlled by a Zen Thermostat) and other non-critical systems.

This is exactly the Use Case I had when @snell wrote this app. Unfortunately, my HVAC system thermostats are not readily replaceable by any of the available Zwave or Zigbee thermostats. :frowning:

Let us know how this works!

S.

1 Like

Will do, there’s quite a backlog of orders for the PW2 - I’ve heard up to 20 weeks.

Let me know how it goes. Plus I am always interested in trying to make any of my drivers more useful so someday once you have yours you can let me know if there is "just this little tweak".

1 Like

Greate work @snell my 3 powerwall and 8K solar should be installed next Thursday. Let me know if you still need any data for testing and I'll be happy to provide.

Kudos

Check it out and if you notice anything missing or things you would like it to do... let me know and I will see if there is any thing I can do to improve the driver. In that case, logs might be useful. Otherwise, enjoy!

I've been using the driver for a few days since my system installation. Do you already capture "nominam_full_pack_energy" that's found under api/system_status this would be handy to be able to track pack degradation over time.

Let me know if you need more details or if it's already available.