[PROJECT] Driver for Connecting to Your Tesla Devices

Description:
This driver connects to locally networked Tesla devices, starting with their Powerwall 2. The end goal is to make it possible for users to check whatever information any a user's Tesla device(s) provide.

In any case, the focus this time is on the local network data you can access from your device(s). As more data is identified, methods understood, and devices supported, they will be added and listed in this Topic.

Driver File(s):
TeslaDriver.groovy - REQUIRED
TeslaChild.groovy - OPTIONAL But if you want to enable child devices you will need it.

Supported Device(s):
Powerwall 2: Currently this is designed around the data that a Powerwall 2 supposedly provides.

Notes:

  • The driver checks for data from devices connected to your local network and you must specify the device IP or hostname.
  • Available within the Hubitat Package Manager (HPM).
  • If you try it out and have feedback, bugs, or suggestions, please post and let me know. I am also always happy to check over sample data if you want to provide some to me. If you post it please make sure to remove any serial # information.
3 Likes

@snell First and foremost, thanks for this!

Installed both drivers, and created a Virtual Device (Powerwall) using the Tesla Connect Driver.

Upon saving the device, it gave me some options, and by selecting connect using network IP, I can find no way to enter the IP address. On a whim, I tried changing the network address of the Virtual Device, but that didn't seem to work.

The code indicates that there should be a dialog. Did I miss a step?

Scott

Same (THANK YOU FOR STARTING THIS @snell )

Actually irrespective of API or IP connection I don't get any means of inputting login info for my powerwall or tesla account.

Debug Info:
dev:17932020-05-19 06:48:41.034 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:48:32.510 pm debugPowerWall - Driver version up to date

dev:17932020-05-19 06:48:28.864 pm infoPowerWall - Updated

dev:17932020-05-19 06:48:28.851 pm debugPowerWall - Refresh rate: 1 minute

dev:17932020-05-19 06:47:54.091 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:46:54.510 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:45:54.067 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:44:54.105 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:43:54.070 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:42:54.077 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:41:54.054 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:40:55.457 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:40:40.153 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:40:05.431 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:39:54.503 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:39:12.028 pm infoPowerWall - Updated

dev:17932020-05-19 06:38:57.266 pm infoPowerWall - Updated

dev:17932020-05-19 06:38:05.081 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:37:05.164 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:36:05.097 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:35:05.391 pm errorPowerWall - Exception: java.net.UnknownHostException: null

dev:17932020-05-19 06:35:01.469 pm errorPowerWall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:17932020-05-19 06:34:27.370 pm infoPowerWall - Updated

dev:17932020-05-19 06:34:03.181 pm infoPowerWall - Updated

dev:17932020-05-19 06:34:03.064 pm infoPowerWall - Installed

oops, meant to replay to the thread, not directly to you @jared.zimmerman!

Ok... Well I definitely need some more error checking in there to prevent all that. Plus I realized I messed up the preferences (I changed some values there but not for the rest...). Revised version coming in a few minutes.

UPDATE: Version 0.1.2 is now posted and should correctly show the Device IP spot for Local Network as well as Email and Password fields for API. This was a goof when I changed the ENUM values to be more human readable. I KNEW I need to change them elsewhere in the code... but forgot before I posted.

Since I have to use a "fake" address to get to a sample, I do not get to use the real methods.

2 Likes

Certainly closer!

dev:17932020-05-19 07:21:46.106 pm errorPowerWall - Exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I think this is that certificate recovery step.

S.

ok tried LAN and API again

LAN give me : * Status : Local Connection Error

API give me : * Status : CONNECTION ERROR

For API just wanted to mention that there is an "Installer" and "Customer" login, in case there is any opportunity to select one or the other (only Customer works)

dev:6432020-05-19 04:38:48.168 pm errorTesla Powerwall - Exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

dev:6432020-05-19 04:38:47.401 pm errorTesla Powerwall - Exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

dev:6432020-05-19 04:38:46.789 pm debugTesla Powerwall - Driver version up to date

dev:6432020-05-19 04:38:45.911 pm infoTesla Powerwall - Updated

dev:6432020-05-19 04:38:45.895 pm debugTesla Powerwall - Refresh rate: 1 minute

dev:6432020-05-19 04:38:36.181 pm errorTesla Powerwall - Exception: java.net.UnknownHostException: null: Name or service not known

dev:6432020-05-19 04:37:47.596 pm debugTesla Powerwall - Driver version up to date

dev:6432020-05-19 04:37:47.271 pm infoTesla Powerwall - Updated

dev:6432020-05-19 04:37:47.257 pm debugTesla Powerwall - Refresh rate: 1 minute

dev:6432020-05-19 04:37:47.221 pm debugTesla Powerwall - Child devices disabled, but had been enabled, deleting child devices

dev:6432020-05-19 04:37:35.839 pm infoTesla Powerwall - Updated

dev:6432020-05-19 04:37:35.786 pm infoTesla Powerwall - Installed

Ok. Version 0.1.3 is now posted. I added a bunch of error checking in (was already working that) and it should ignore SSL issues with Tesla's self-signed certificates.

I love this near-realtime feedback!

1 Like

Yeah, I went to the URL on my bowser, and the certificate authority is invalid. We'll probably have to bypass this.

Really close now:

dev:17932020-05-19 07:52:47.069 pm errorPowerWall - Exception: groovy.json.JsonException: Lexing failed on line: 1, column: 2, while reading 's', no possible valid JSON value or punctuation could be recognized.

I saw that mentioned online. Most people either bypass it or just accept Tesla's certificate as valid and add it to their computer. I get the same thing with the printers at work. In any case, I do not think we can (or want to) add certificates to our Hubitat, so bypassing (ignoring) it for now.

Seems like the best plan. In the Schiavo link, there's essentially an import statement. I seem to recall doing that when I was playing with the Python stuff.

S.

Ps. For my part, its almost bedtime, so real-time might become tomorrow time soon! :wink:

No problem. When you are done, you are done.

Version 0.1.4 is posted. All it does is add a bit more trace logging for Local data. If you can grab what it returns after "Local Aggregate Response"... in the log, that should be what it actually returned. Tough to diagnose a json issue when I cannot see the json that came back. :wink:

Sorry, lots of user error between now and your previous, but I got there:


dev:1793
2020-05-19 08:04:58.918 pm tracePowerWall - Local Aggregate Response = [site:[last_communication_time:2020-05-19T17:05:02.283210386-07:00, instant_power:1883.3600463867188, instant_reactive_power:-1789.7100219726562, instant_apparent_power:2598.096808641885, frequency:60.060001373291016, energy_exported:2594458.884174022, energy_imported:27777946.727507357, instant_average_voltage:122.80500030517578, instant_total_current:0, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000], battery:[last_communication_time:2020-05-19T17:05:02.290244655-07:00, instant_power:-10, instant_reactive_power:650, instant_apparent_power:650.0769185258004, frequency:60.016000000000005, energy_exported:3410, energy_imported:280520, instant_average_voltage:245.5, instant_total_current:-0.4, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000], load:[last_communication_time:2020-05-19T17:05:02.283210386-07:00, instant_power:1864.6162016238027, instant_reactive_power:-1038.9910358793522, instant_apparent_power:2134.5481845101617, frequency:60.060001373291016, energy_exported:0, energy_imported:33168874.023333333, instant_average_voltage:122.80500030517578, instant_total_current:15.183552762429462, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000], solar:[last_communication_time:2020-05-19T17:05:02.283496716-07:00, instant_power:4.560000061988831, instant_reactive_power:84.29999923706055, instant_apparent_power:84.42324011748038, frequency:60.060001373291016, energy_exported:8263085.413341232, energy_imported:589.2333412310857, instant_average_voltage:122.81499862670898, instant_total_current:0, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000]]

Ok. There are some differences in structure compared to what I based mine on. It will take me a bit, but this is why real samples are valuable. I will post the update as soon as I can.

No worries at all.
In interpreting the JSON, it might be valuable to know my system has 2 Powerwall 2s and 18 panels plus a Solaredge inverter.

S.

Posted version 0.1.5 now. Not sure if this will help, but I am having it specifically request json content. I had read it would return json, but what it gave you before specifically is NOT json formatted.

The good news is that the data returned only had one element I did not have listed already "timeout"... which appears basically meaningless, but might as well include it.

If I cannot get it to provide nice json to begin with it will require a bit more parsing to make it happy, something I will not be finishing tonight.

1 Like

Result is definitely different, I don't recall the Solar tag from earlier data: disregard I looked again, it was there.

dev:17932020-05-19 08:52:06.412 pm errorPowerWall - Exception: groovy.json.JsonException: Lexing failed on line: 1, column: 2, while reading 's', no possible valid JSON value or punctuation could be recognized.

dev:17932020-05-19 08:52:06.410 pm tracePowerWall - Local Aggregate Response = [site:[last_communication_time:2020-05-19T17:52:09.783280858-07:00, instant_power:2427.8800048828125, instant_reactive_power:-1276.1600036621094, instant_apparent_power:2742.842626374441, frequency:60, energy_exported:2594458.884174022, energy_imported:27779630.37722958, instant_average_voltage:122.20500183105469, instant_total_current:0, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000], battery:[last_communication_time:2020-05-19T17:52:09.790178769-07:00, instant_power:-20, instant_reactive_power:330, instant_apparent_power:330.6055050963308, frequency:60.019000000000005, energy_exported:3410, energy_imported:280520, instant_average_voltage:244.60000000000002, instant_total_current:-0.4, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000], load:[last_communication_time:2020-05-19T17:52:09.783165193-07:00, instant_power:2439.830035024823, instant_reactive_power:-877.0393942584394, instant_apparent_power:2592.675972598666, frequency:60, energy_exported:0, energy_imported:33170563.130833335, instant_average_voltage:122.20500183105469, instant_total_current:19.965058700279926, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000], solar:[last_communication_time:2020-05-19T17:52:09.783165193-07:00, instant_power:6.419999837875366, instant_reactive_power:83.88999938964844, instant_apparent_power:84.13529815430343, frequency:60, energy_exported:8263090.871119009, energy_imported:589.2333412310857, instant_average_voltage:122.22000122070312, instant_total_current:0, i_a_current:0, i_b_current:0, i_c_current:0, timeout:1500000000]]