[PROJECT] Driver for Connecting to Your Tesla Devices

Just making sure you saw the collapsed section at the very bottom of [PROJECT] Driver for Connecting to Your Tesla Devices under the screenshots from the mobile app

I had not... but all that shows is the connections for the Powerwalls. I wonder why it does not show all the rest. Should not need Trace on for it to show up... At debug logging you should still have seen messages like "Connected to Tesla device for Aggregate." and related ones for the other areas it queries besides the Powerwalls.

Oh well. I have a driver update that will be posted in a couple minutes, then done for the night.

UPDATE:
Version 0.2.2 of the TeslaDriver is posted. It includes some additional parsing of data, ignoring Serial Numbers from now on (they will still show in mass raw data though, sorry), as well as trying to poll a couple more sections of data. I am also tried to make the "grid_status" into a more useful "Grid Status" that has more user-friendly info.
Version 0.1.2 of the TeslaChild is posted. It was altered to add the new Grid Status attribute and to add capabilities for when I post voltage, power, and such to it (not being done yet).

I do see dev:7052020-05-21 05:55:20.590 pm debugTesla Powerwall - Connected to Tesla device for Aggregate.

Wow. You guys have been busy. It's hard to keep up!

I edited my post to remove the serial numbers for my batteries, cart and horse spring to mind, but why not!?

I'll scan for the Device Data tag in my data.

Scott

Ah, I did get one that said "Powerwall data = and a whole bunch of data, but never "Device data =" or any variation thereof.

Latest data (sans Serials) --- stripped some urls to my devname just make the line a little narrower.

2020-05-22 02:46:28.923 pm debugPowerWall - Connected to Tesla device for Powerwalls.
2020-05-22 02:46:28.922 pm tracePowerWall - Ignoring update_diagnostic
2020-05-22 02:46:28.913 pm tracePowerWall - Child State: grid_state = Grid_Uncompliant
2020-05-22 02:46:28.901 pm tracePowerWall - Child State: type = acpw
2020-05-22 02:46:28.889 pm tracePowerWall - Child State: bc_type =
2020-05-22 02:46:28.866 pm tracePowerWall - Child State: PackageSerialNumber = --
2020-05-22 02:46:28.841 pm tracePowerWall - Child State: PackagePartNumber = 2012170-00-A
2020-05-22 02:46:28.829 pm tracePowerWall - Child State: under_phase_detection = false
2020-05-22 02:46:28.825 pm tracePowerWall - Ignoring commissioning_diagnostic
2020-05-22 02:46:28.816 pm tracePowerWall - Child State: updating = false
2020-05-22 02:46:28.803 pm tracePowerWall - Child State: Type =
2020-05-22 02:46:28.788 pm tracePowerWall - Child State: grid_reconnection_time_seconds = 0
2020-05-22 02:46:28.784 pm tracePowerWall - Powerwall -- size = 11
2020-05-22 02:46:28.784 pm tracePowerWall - Ignoring update_diagnostic
2020-05-22 02:46:28.775 pm tracePowerWall - Child State: grid_state = Grid_Uncompliant
2020-05-22 02:46:28.758 pm tracePowerWall - Child State: type = acpw
2020-05-22 02:46:28.727 pm tracePowerWall - Child State: bc_type =
2020-05-22 02:46:28.715 pm tracePowerWall - Child State: PackageSerialNumber = --
2020-05-22 02:46:28.702 pm tracePowerWall - Child State: PackagePartNumber = 2012170-00-A
2020-05-22 02:46:28.690 pm tracePowerWall - Child State: under_phase_detection = false
2020-05-22 02:46:28.686 pm tracePowerWall - Ignoring commissioning_diagnostic
2020-05-22 02:46:28.677 pm tracePowerWall - Child State: updating = false
2020-05-22 02:46:28.658 pm tracePowerWall - Child State: Type =
2020-05-22 02:46:28.638 pm tracePowerWall - Child State: grid_reconnection_time_seconds = 0
2020-05-22 02:46:28.622 pm tracePowerWall - Powerwall -- size = 11
2020-05-22 02:46:28.621 pm tracePowerWall - # Powerwalls = 2
2020-05-22 02:46:28.247 pm tracePowerWall - Powerwalls data = {"enumerating":false,"updating":false,"checking_if_offgrid":false,"running_phase_detection":false,"phase_detection_last_error":"phase detection not run","bubble_shedding":false,"on_grid_check_error":"on grid check not run","grid_qualifying":false,"grid_code_validating":false,"phase_detection_not_available":true,"powerwalls":[{"Type":"","PackagePartNumber":"2012170-00-A","PackageSerialNumber":"--","type":"acpw","grid_state":"Grid_Uncompliant","grid_reconnection_time_seconds":0,"under_phase_detection":false,"updating":false,"commissioning_diagnostic":{"name":"Commissioning","category":"InternalComms","disruptive":false,"inputs":null,"checks":[{"name":"CAN connectivity","status":"fail","start_time":"2020-05-22T11:46:31.964161316-07:00","end_time":"2020-05-22T11:46:31.964166316-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Enable switch","status":"fail","start_time":"2020-05-22T11:46:31.964168983-07:00","end_time":"2020-05-22T11:46:31.964171316-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Internal communications","status":"fail","start_time":"2020-05-22T11:46:31.964173649-07:00","end_time":"2020-05-22T11:46:31.964175649-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Firmware up-to-date","status":"fail","start_time":"2020-05-22T11:46:31.964177983-07:00","end_time":"2020-05-22T11:46:31.964180316-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}}]},"update_diagnostic":{"name":"Firmware Update","category":"InternalComms","disruptive":true,"inputs":null,"checks":[{"name":"Powerwall firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Battery firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Inverter firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Grid code","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null}]},"bc_type":""},{"Type":"","PackagePartNumber":"2012170-00-A","PackageSerialNumber":"--","type":"acpw","grid_state":"Grid_Uncompliant","grid_reconnection_time_seconds":0,"under_phase_detection":false,"updating":false,"commissioning_diagnostic":{"name":"Commissioning","category":"InternalComms","disruptive":false,"inputs":null,"checks":[{"name":"CAN connectivity","status":"fail","start_time":"2020-05-22T11:46:31.964830645-07:00","end_time":"2020-05-22T11:46:31.964835312-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Enable switch","status":"fail","start_time":"2020-05-22T11:46:31.964837645-07:00","end_time":"2020-05-22T11:46:31.964839979-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Internal communications","status":"fail","start_time":"2020-05-22T11:46:31.964841979-07:00","end_time":"2020-05-22T11:46:31.964844312-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Firmware up-to-date","status":"fail","start_time":"2020-05-22T11:46:31.964846312-07:00","end_time":"2020-05-22T11:46:31.964848645-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}}]},"update_diagnostic":{"name":"Firmware Update","category":"InternalComms","disruptive":true,"inputs":null,"checks":[{"name":"Powerwall firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Battery firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Inverter firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Grid code","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null}]},"bc_type":""}],"has_sync":true,"sync":{"updating":false,"commissioning_diagnostic":{"name":"Commissioning","category":"InternalComms","disruptive":false,"inputs":null,"checks":[{"name":"CAN connectivity","status":"fail","start_time":"2020-05-22T11:46:31.965790639-07:00","end_time":"2020-05-22T11:46:31.965794973-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}},{"name":"Firmware up-to-date","status":"fail","start_time":"2020-05-22T11:46:31.965797639-07:00","end_time":"2020-05-22T11:46:31.965799639-07:00","message":"Cannot perform this action with site controller running. From landing page, either "STOP SYSTEM" or "RUN WIZARD" to proceed.","results":{},"debug":{}}]},"update_diagnostic":{"name":"Firmware Update","category":"InternalComms","disruptive":true,"inputs":null,"checks":[{"name":"Synchronizer firmware","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null},{"name":"Grid code","status":"not_run","start_time":null,"end_time":null,"progress":0,"results":null,"debug":null}]}},"states":[]}
2020-05-22 02:46:28.486 pm debugPowerWall - Connected to Tesla device Registration.
2020-05-22 02:46:28.481 pm debugPowerWall - Connected to Tesla device System Status.

@scottgu3: Your last post of stats has the serial #s listed in it... Another "smart" thing from Tesla... And another spot in my code to hide it from logging...

Anyways, I think I have the Powerwalls pretty well set. Now if only I can get the specific devices to report. I may just give up trying to be "dynamic" about it and hard-code their queries, since for some reason there is no logging of them being attempted. Something to work on tonight.

Yup, missed one...lol

Thanks!

You know, I'm not sure you'd really need to strip that. If I'm looking at it locally, then it is on the inside of my network. If someone in my house resets my Tesla account that way...well, I have bigger problems than my Tesla account anyway. The only place I can think it would matter (maybe, but it's a stretch) is if I post it here...in a public forum.

S.

Exactly... So I am not worried about it getting posted as the device name or as a state to the child devices or such... but I am trying to remove it from any logs that someone might post. Just in case.

Plus, you guys have been putting so much work in to trying it out I want to make sure it is done correctly.

Thanks! You're putting in all the work, I just get to play with the new toys as they hit the street.

I need to figure out (remember) how to authenticate over network interface. I wonder if some of this data would be populated if I logged in and messed around (diagnostic data for example).

Short of cutting the power to the house, I don't know how I'd check some of these values. One that interests me is:

"checking_if_offgrid":false

As in: does it mean the Grid is working, and I'm not "offgrid", or does it (more likely) mean I'm running a grid tied system -- e.g. "ongrid".

I remember browsing around using the python tools fron Schiavo, and being fascinated, but yeah, that was as far as I got...lol

S.

I had a grid power outage a few days back @snell has the logs for that!

Whoa! this is getting good

Current States

  • Grid Status : Grid up
  • Version : New patch 0.2.2 available
  • battery : 99.99269886467346

State Variables

  • country : United States
  • nominal_system_energy_kWh : 13.5
  • connected_to_tesla : true
  • timezone : America/Los_Angeles
  • Driver : TeslaDriver
  • registered : true
  • utility : Pacific Gas and Electric Company
  • battery : 99.99269886467346
  • grid_code : 60Hz_240V_s_UL1741SA:2019_California
  • running : true
  • grid_phase_setting : Split
  • Version : 0.2.1
  • nominal_system_power_kW : 10
  • percentage : 99.99269886467346
  • grid_services_active : false
  • state : California
  • grid_services : true
  • max_site_meter_power_kW : 1000000000
  • retailer : Silicon Valley Clean Energy (SVCE)
  • grid_freq_setting : 60
  • limited_warranty : true
  • distributor : *****
  • Grid Status : Grid up
  • site_name : Home Energy Gateway
  • marketing : true
  • grid_voltage_setting : 240
  • grid_status : SystemGridConnected
  • min_site_meter_power_kW : -1000000000
  • privacy_notice : true
  • timed_out_registration : false
  • region : UL1741SA-CA:2019
  • status : StatusUp

Battery (Child)

State Variables

  • grid_reconnection_time_seconds : 0
  • Type :
  • updating : false
  • Version : 0.1.2
  • Driver : TeslaChild
  • under_phase_detection : false
  • PackagePartNumber : 1092170-53-J
  • bc_type :
  • type : acpw
  • grid_state : Grid_Uncompliant

Would you be open to some help/suggestions on State Variable organization suggestions?

I copied everything into an editable sheet (no login needed) and took a pass at organizing the groupings, I'll work on names in a separate column as well as some notes and questions

Totally open. Right now I am just passing the exact names Tesla provides, but making them more reasonable is definitely one of the items on my ToDo list. Feedback from actual users is always appreciated!

logs from 0.2.2

dev:7052020-05-22 02:01:23.400 pm debugTesla Powerwall - Connected to Tesla device for Aggregate.

dev:7052020-05-22 02:01:23.393 pm debugTesla Powerwall - Connected to Tesla device Sitemaster.

dev:7052020-05-22 02:01:23.377 pm debugTesla Powerwall - Connected to Tesla device Grid Status.

dev:7052020-05-22 02:00:23.966 pm debugTesla Powerwall - Connected to Tesla device for Powerwalls.

dev:7052020-05-22 02:00:23.654 pm debugTesla Powerwall - Connected to Tesla for Site Info.

dev:7052020-05-22 02:00:23.646 pm debugTesla Powerwall - Unhandled data:max_system_power_kW=0

dev:7052020-05-22 02:00:23.633 pm debugTesla Powerwall - Unhandled data:max_system_energy_kWh=0

dev:7052020-05-22 02:00:23.574 pm debugTesla Powerwall - Connected to Tesla device Sitemaster.

dev:7052020-05-22 02:00:23.544 pm debugTesla Powerwall - Device data = {"max_site_meter_power_kW":1000000000,"min_site_meter_power_kW":-1000000000,"nominal_system_energy_kWh":13.5,"nominal_system_power_kW":10,"max_system_energy_kWh":0,"max_system_power_kW":0,"site_name":"Home Energy Gateway","timezone":"America/Los_Angeles","grid_code":"60Hz_240V_s_UL1741SA:2019_California","grid_voltage_setting":240,"grid_freq_setting":60,"grid_phase_setting":"Split","country":"United States","state":"California","distributor":"*","utility":"Pacific Gas and Electric Company","retailer":"Silicon Valley Clean Energy (SVCE)","region":"UL1741SA-CA:2019"}

dev:7052020-05-22 02:00:23.529 pm debugTesla Powerwall - Connected to Tesla device for Aggregate.

dev:7052020-05-22 02:00:23.495 pm debugTesla Powerwall - Connected to Tesla device Grid Status.

dev:7052020-05-22 02:00:23.456 pm debugTesla Powerwall - Connected to Tesla device Registration.

dev:7052020-05-22 02:00:23.424 pm debugTesla Powerwall - Connected to Tesla device System Status.

@snell @scottgu3 finished a first pass at the sheet of labels and values. Feel free to comment or change things, there was a fair number of values that are empty, blank, duplicative, or mysterious, web searches didn't yield anything userful for most of them.

No problem with some of the variable names... but some like "battery"... that one is actually a Hubitat attribute, so that the device can be used by the Battery capability in Hubitat. If it is not named that, it will not work automatically. Similar thing with voltage. I also need to round such numbers... not sure why Tesla wants it THAT specific.

If you want to see all the "handled" variables, they are in the ProcessData function about 2/3 of the way down the driver. There is a small section of "ignored" ones for stuff like the Serial #s and Diagnostic "junk".

Also not sure about the proposed groupings. The child devices are generated based on the data returned and there is no way to "order" State Variables or Current States. It would be easy enough to group them in an app (which I do not plan on building at this time). But the data is processed as it comes in so if a variable does not belong to a particular batch of data it is more difficult to put it elsewhere (especially if children are not enabled).

Updates for both TeslaDriver & TeslaChild (0.2.3 and 0.1.3 respectively). I made a lot of the variables more "human friendly" per @jared.zimmerman's recommendations (not everything yet though). I also might have found some more data to pull in. Plus, more of the important data is being treated as Events.

All the additional attributes (to support the Events) are the cause for the child driver to require update as well.

1 Like

Uh Oh: Bad Stuff Happens -- updated to latest Driver and Child Driver.

dev:17932020-05-22 07:54:05.745 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 651 (ParseSiteInfo)

dev:17932020-05-22 07:54:05.639 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 651 (ParseSystemStatus)

dev:17932020-05-22 07:54:05.596 pm debugPowerWall - Device data = {"max_site_meter_power_kW":1000000000,"min_site_meter_power_kW":-1000000000,"nominal_system_energy_kWh":13.5,"nominal_system_power_kW":10,"max_system_energy_kWh":0,"max_system_power_kW":0,"site_name":"Haymarket House","timezone":"America/New_York","grid_code":"60Hz_240V_s_IEEE1547:2003","grid_voltage_setting":240,"grid_freq_setting":60,"grid_phase_setting":"Split","country":"United States","state":"Virginia","distributor":"","utility":"Northern Virginia Electric Cooperative","retailer":"","region":"IEEE1547"}

dev:17932020-05-22 07:54:05.591 pm errorPowerWall - Error connecting to Tesla for System Testing. 403

dev:17932020-05-22 07:54:05.581 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 651 (ParseGridStatus)

dev:17932020-05-22 07:54:05.569 pm errorPowerWall - Error connecting to Tesla for Meter Readings. 403

dev:17932020-05-22 07:54:05.568 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 651 (ParseRegistration)

dev:17932020-05-22 07:54:05.553 pm tracePowerWall - SystemStatus data = {"percentage":98.49763741367474}

dev:17932020-05-22 07:54:05.552 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 651 (ParseSitemaster)

dev:17932020-05-22 07:54:05.459 pm tracePowerWall - Registration data = {"privacy_notice":true,"limited_warranty":true,"grid_services":true,"marketing":false,"registered":true,"timed_out_registration":false}

dev:17932020-05-22 07:54:05.453 pm tracePowerWall - GridStatus data = {"grid_status":"SystemGridConnected","grid_services_active":false}

dev:17932020-05-22 07:54:05.442 pm tracePowerWall - Sitemaster data = {"status":"StatusUp","running":true,"connected_to_tesla":true}

dev:17932020-05-22 07:54:05.437 pm debugPowerWall - Connected to Tesla for Aggregate.

dev:17932020-05-22 07:54:05.436 pm tracePowerWall - Aggregate Devices = 0

Also noted this in the TeslaDriver instance events log:

Status Local Connection Failed DEVICE 2020-05-22 08:17:05.338 PM EDT
Status Local Connection Good DEVICE 2020-05-22 08:17:05.306 PM EDT
Status Local Connection Failed DEVICE 2020-05-22 08:17:05.237 PM EDT
Status Local Connection Failed DEVICE 2020-05-22 08:16:05.670 PM EDT
Status Local Connection Failed DEVICE 2020-05-22 08:16:05.609 PM EDT
Status Local Connection Good DEVICE 2020-05-22 08:16:05.473 PM EDT
Status Local Connection Good DEVICE 2020-05-22 08:15:05.641 PM EDT
Status Local Connection Failed DEVICE 2020-05-22 08:15:05.623 PM EDT
Status Local Connection Failed DEVICE 2020-05-22 08:15:05.481 PM EDT
Status Local Connection Good DEVICE 2020-05-22 08:14:05.452 PM EDT

S.

Ok... So the line 651 was because sometimes things are null, but I was testing them regardless, so I added a check to make sure they are not before that.

Meter Readings & System Testing were things I saw mentioned that were possibly no longer valid anymore but they had potentially interesting information so I wanted to try anyways. But they are gone. So they are gone from the code as well.

You should be able to switch over to Debug logging for now. It will eliminate the sections that should now be "understood" that Trace shows, but still let us know if something is missing.

Anyways... Version 0.2.4 of TeslaDriver is now posted. No new changes to the Child driver.

It can wait...lol. I'm just about asleep! Enjoy your weekend!

S.