[PROJECT] Driver for Connecting to Your Tesla Devices

For me, these changes wouldn't break anything.

S

The TeslaDriver is in HPM already. It was one of the first I did, and one of the three I have loaded into it (out of the 12+ published drivers I have in the community).

4 Likes

I noticed mine was out of date yesterday and it wasn't listed in my HPM installs, so I assumed it wasn't. I see it now; I've done a Match Up to link it up. I should have tried that first. Sorry for the confusion!

I am trying to understand the meters/aggregate data and would appreciate some guidance on how to use it. What I am trying to do is get daily stats on solar generation, home use and battery provided (like what the Tesla app provides). Does this require me to pull that data periodically and then do the math? If so which values do I need to use?

For some reason, I cannot connect to my Powerwall from any device that is not directly plugged into my ATT router (I have mesh system in bridge mode behind the ATT router), so am trying this in Node-RED.

The running totals for all export/import are in the data, so as long as you poll that around midnight, you can establish a base for your daily totals, and generate a graph if you poll more frequently.

e.g. this driver shows for me today:

  • Battery Energy Exported : 2700590
  • Battery Energy Imported : 2997520
  • Load Energy Imported : 12152321
  • Solar Energy Exported : 8089294
  • Solar Energy Imported : 8680

cool, the battery export / battery import is 90% - the expected round trip performance.

1 Like

@brad I don't think you are posting in the right thread. This one only talks to PowerWalls, not cars.

Based upon the function names, I suspect you meant this: Tesla Integration to Remind Us To Plug The Car In - #163 by kahn-hubitat

Thank you!

I finally got my Powerwall 2 installed today and @snell your Hubitat driver works great!

1 Like

Glad to hear it!

As always, I am glad for feedback (positive OR constructive negative) and/or requests... so if you spot anything, let me know.

1 Like

Hi @snell do you ever experience the Tesla App stopping pulling data/status and need to force a login to restore the connection?

I've had this happen a few times now and it'd be great if there was some sort of recovery logic in the app to restore the session.

I do not develop a Tesla app for Hubitat. If you are talking about this driver, I can check about making the reauthorization more user-controllable. Trying to perform reauthorizations then resuming a query that failed is usually more hassle than it is worth because of response timings.

I do not actually have a Tesla PowerWall myself, so I just need to go by the feedback here of what works and what does not. Plus if Tesla changes things with firmware updates.

1 Like

Yes, sorry I meant the driver. It’s the parent driver that I’ve had to re-logon to resolve this.

Would it be possible to implement a timeout, eg if no data is revived for say 1 hour, then re-authenticate?

Or perhaps Tesla needs the logon to be refreshed every 5-7 days.

Edit I noticed there is a last_communication_time and a Last Login state that could be used to implement a re-logon day every 5 days or something like that.

I use the device watchdog app to let me know when I need to log back in. I believe it uses the "Last Activity" to tell when a device is not updating and that is working for this driver.

I do know this driver has a local connection succeeded or failed state. Could probably use the failed state to trigger a re-auth and add a counter so it only does say 5 auto re-auths in a row before stopping. That or some sort of timeout. Like, connection failed, re-auth and repeat every 30 min till connection works.

1 Like

That sounds ideal.

I have tried similar "failed" on other drivers in the past. They never seemed to work quite well enough especially with multiple different calls and commands (I either had to build the logic many times or use the same but have it handle what command/action was being performed, which causes a lot of headaches as new ones get added).

I will see about adding some changes to the reauthorization option (like many of my other drivers). That usually seems to work most consistently for those. If it does not work out, I will look at providing alternatives (like retries again). Hopefully I will have some time to work on this late tonight.

1 Like

Thank you, much appreciated.

Updated Version(s):

  • TeslaDriver.groovy = 1.2.6

Change(s):

  • Added ReauthorizationRate to the parent device preferences. The default value is 24 hours but it can go down to 3 hours. Saving Preferences (after this update) will create a new scheduled task to perform a Login at that frequency in order to maintain the cookie and authentication credentials.
  • Changed the Driver Version checks to match my newer methods.

Note(s):

  • I recommend saving preferences on the parent device after updating to the 1.2.6 version. You may still see a Driver Status indicating an update is available (until the next daily version checking occurs) but the Driver Version should state 1.2.6. Saving Preferences will also make sure that the new task is scheduled for the reauthorization.
  • As always, I must note that I do not have a PowerWall. This is a read-only style driver though (I have no functions to set ANYTHING on the PowerWall) so it is pretty safe.
2 Likes

Thank you @snell much appreciated. :sunglasses:

Hope it helps. Better yet... wait a couple days (or less if there is an issue of course) and let me know if it is still working nicely. :smile:

1 Like

looking good so far. :+1:

it was usually a weekly failure, so performing a re-auth every 24 hours should be perfect.