Tesla Battery Gateway Plugin

rmo
Posts: 5
Joined: Mon Feb 20, 2017 9:42 pm

Re: Tesla Battery Gateway Plugin

Post by rmo »

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?
User avatar
GlennNZ
Posts: 1873
Joined: Sun Dec 07, 2014 3:33 pm
Location: Central Coast, Australia

Tesla Battery Gateway Plugin

Post by GlennNZ »

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
Post Reply

Return to “Tesla Battery”