mlowijs / tesla_api

Lightweight Python API client for the Tesla API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecated endpoint

scienceintheshed opened this issue · comments

It appears that one of the endpoints to get info from list_energy_sites() endpoint has been deprecated.

# Simple code to demonstrate problem

from tesla_api import TeslaApiClient
from datetime import datetime
import time

now = datetime.now()
print(now)
print("Starting Tesla5 program...")

client = TeslaApiClient("username", "password")

energy_sites = client.list_energy_sites()
print("Number of energy sites = %d" % (len(energy_sites)))
assert(len(energy_sites)==1)

# Output

==================== RESTART: C:/Python/Powerwall/Tesla5B.py ===================
2021-01-30 10:28:55.929762
Starting Tesla5 program...
Traceback (most recent call last):
  File "C:/Python/Powerwall/Tesla5B.py", line 11, in <module>
    energy_sites = client.list_energy_sites()
  File "C:/Python/Powerwall\tesla_api\__init__.py", line 94, in list_energy_sites
    return [Energy(self, products['energy_site_id']) for products in self.get('products')]
  File "C:/Python/Powerwall\tesla_api\__init__.py", line 69, in get
    self.authenticate()
  File "C:/Python/Powerwall\tesla_api\__init__.py", line 55, in authenticate
    self._token = self._get_new_token()
  File "C:/Python/Powerwall\tesla_api\__init__.py", line 33, in _get_new_token
    raise AuthenticationError(response_json['response'])
tesla_api.AuthenticationError: Authentication to the Tesla API failed: endpoint_deprecated:_please_update_your_app.
>>>

Feel free to make a PR if you know how to update it. I don't have solar or powerwall to test this myself.

Problem is I'm not sure what's broken...still trying to work it out.

Actually, I misread the traceback. I think they must have disabled the password login.

Therefore this is probably a duplicate of #31.

Tesla have disabled the v2 authentication endpoint, meaning that v3 / MFA flow is now required:

timdorr/tesla-api#215

As I suspected. Closing as duplicate of #31.

Thanks, have started following. Hopefully someone will post a fix as I have a few scripts that are now broken.

If nobody else has a go at it, I'm sure I'll get round to it in a few weeks.