Tesla Battery Gateway Plugin

Posted on
Tue Apr 09, 2024 9:21 pm
rmo offline
Posts: 5
Joined: Feb 20, 2017

Re: Tesla Battery Gateway Plugin

Hey Glen,

I'd like to be able to control the operation mode of my Tesla Powerwalls and flip them to backup when charging an EV to prevent draining them.

I used the Auth for Tesla iOS App to generate a refresh token and added it to the config for your plugin, but when restarting I get the following error:

Code: Select all
   Tesla Battery Error             Error Getting Online Site Info : KeyError('access_token')
Traceback (most recent call last):
  File "plugin.py", line 765, in parseonlineSiteInfo
    self.getauthTokenOnline()
  File "plugin.py", line 542, in getauthTokenOnline
    self.logger.debug("{}".format(self.tesla.token["access_token"]) )
                                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'


I'm using version 0.8.11. Any thoughts?

Posted on
Fri Apr 12, 2024 7:26 pm
GlennNZ offline
User avatar
Posts: 1574
Joined: Dec 07, 2014
Location: Central Coast, Australia

Tesla Battery Gateway Plugin

After a whole lot of reading, and reviewing the code - Version 0.8.11 remains working on my testing.

Double check you are on 0.8.11 because 0.8.9 will give that error

If your username or password is incorrect that would likely also fail the connection. This is the Tesla account details.

It seems however that there are major Tesla changes, hasn't affected battery as yet but soon:

For this level of access to work in future: Apparently will need

But have updated to version :

0.9.0
(in Plugin Store)
Updates some of the endpoints - it's possible restricted access in your account caused an issue I can't see.


The changes Tesla have implemented for access for vehicles (?) are below, this is probably coming for this online battery control//access. Hopefully the local data which is the mainstay of the plugin doesn’t change. Obviously if this happens I don’t believe trying to jump through these below hoops is worthwhile.

Tesla changes, What you need
A Tesla account
For commands: A registered domain for public key hosting with a valid SSL certificate
Until Tesla fixes the registration for hobbyist users, you need a VAT ID number. This does not need to be an exisiting number, it just needs to adhere to the rules for a valid VAT number. Google for what a VAT number looks like in your country/region and use your home adress.
A mobile phone with the Tesla app installed for key installation to the car
A Tesla car helps a lot
Steps:
Set up a developer account at Tesla, see tutorial by Shankar
generate a public/private key pair for Tesla Vehicle Commands
instruct you, how to host your public key in the /.well-known section of your website
get a partner authentication token
use this token to register a customer account (this may be the same as your developer account - you are your own customer)
Check if Tesla has your public key recognized
Request authorization permissions from a customer (for more than one customer, the library has to be extended)
Install the public key to the customers car
Get vehicle data
Send commands to the car

Who is online

Users browsing this forum: No registered users and 3 guests