Tesla Integration not Working since 1/30/21

Tesla configuration doesn’t seem to be working all sensors and switches are unavailable. See below for the error message from the log. Did Tesla change anything on the API recently?

2021-01-30 14:43:42 ERROR (MainThread) [homeassistant.components.tesla.config_flow] Unable to communicate with Tesla API:

It started about 24 hours back, until then everything was working fine. I can still access the vehicle using the Tesla App and online - with same credentials as provided to HA.

Seems like at least one other person has the same issue. Can someone please take a look?

3 Likes

Getting the same thing here.

Bump - anyone knows why this is or if someone is working on a fix.

Seems like Tesla changed something in the way they handle authentications.
Not sure, if anyone is working on a fix for the integration.

1 Like

Thanks. I guess I will disable the integration and remove all Tesla related views from my lovelace dashboard for now.

Yep, same issue here. Tried to delete and re-add the integration but all I get is “Unable to communicate with Tesla API:”

Same thing here

Same here.

Has anyone filed a bug/issue report on github related to this? I’m unsure where this should be filed under - HA core issue or something else. If someone can provide guidance or file it that would be great. Thanks.

1 Like

Same issue here as well.

No need to file a bug report. The people maintaining this integration are aware of the changes Tesla have made to the authentication process (the ‘oAuth flow’). There is a quick solution found to be working, but that does not conform to (for ease of explanation) HA principles. It’s proving to be a bit of a tricky solution to get it to work as it should. If you’re not a coding wizard or authentication expert, all you can do (and by the looks of it, have already done) is to just ‘sit this one out’ until the integration is updated in a new HA release.

Some extra information: this feature/change might even ‘bug’ you when using the Tesla app. If (verified by me as an iOS user) for instance you haven’t detected any interruption of service in your Tesla app use, DON’T ENABLE OR DISABLE the FaceID function. This will break your current login token, and will set you up with an app that can no longer communicate with your car. Logging out and back in the app will not help, as you will encounter an API error when logging in again. This is caused by your ‘old’ login tokens that are still stored inside the app storage. The only real ‘fix’ at that point is to remove the app completely from your phone (which deletes all existing login tokens on your phone) and reinstall and login to the app. This will have you back up and running immediately. The old ‘have you tried removing and than installing it again?’-trick right there…

I realize this might be a bit of information overkill, but if it helps anyone encountering login issues with the Tesla app outside of Home Assistant in the coming days… well, there’s that. :wink:

6 Likes

Thanks. I did file one before here and it was closed because there was already one in the works and a lot of activity has been happening around it. Looks like we will need to wait for the next update of HA Core. There was talks about this integration being ported over to HACS for a quicker resolution but it is unlikely, not sure. Anyways thanks for the update.

So far on the Android app everything does work fine. I did a recent password change on the web (so was logged out of the app and had to login again ), no issues there as well and it seems to have worked fine.

Thank you for the extensive write up @dikkertjedap . I only noticed that the integration was broken when I came out to my car this morning and realized I had forgotten to plug it in. I have an automation that’s supposed to tell me when that happens and of course, didn’t get the notification…

Tesla app works fine for now and I’ll be sure to follow your guidance should it break.

Any update on this, any hack we can use in the meantime?

If you haven’t updated already: the integration is fixed in the last update 2021.2.3!

2 Likes

Thank you @dikkertjedap !!! I’m updating core now and can’t wait to have my Tesla integration back! Thanks so much for the efforts and the note letting me know!

1 Like

Thanks for the call out. I had updated core earlier but did not re-add the integration until I read your post. Appreciate the call out.

Edit: not working for me, seems like the authorization works (after quite a delay) but the entities are not available. Did it work for anyone?

1 Like

I also just updated, but neither got a prompt to re-authenticate nor are my sensors working.

My logs have a bunch of Tesla related errors:

Logger: homeassistant
Source: components/tesla/config_flow.py:84
First occurred: 10:46:14 PM (1 occurrences)
Last logged: 10:46:14 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_init
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/tesla/config_flow.py", line 84, in async_step_reauth
    self.username = data[CONF_USERNAME]
KeyError: 'username'
Logger: homeassistant.components.tesla
Source: components/tesla/__init__.py:167
Integration: Tesla (documentation, issues)
First occurred: 10:46:06 PM (1 occurrences)
Last logged: 10:46:06 PM

Unable to communicate with Tesla API: UNAUTHORIZED
Source: components/tesla/__init__.py:229
Integration: Tesla (documentation, issues)
First occurred: 10:46:06 PM (1 occurrences)
Last logged: 10:46:06 PM

Credentials are no longer valid. Please reauthenticate

I am seeing an error as well. I pulled 2021.2.3, deleted the Tesla integration, and re-added it. Here’s what the logs show:

2021-02-14 19:51:24 ERROR (MainThread) [homeassistant.components.tesla] Error fetching tesla data: Error communicating with API: 
2021-02-14 19:55:01 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 71, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 106, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 155, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/tesla/config_flow.py", line 57, in async_step_user
    info = await validate_input(self.hass, user_input)
  File "/usr/src/homeassistant/homeassistant/components/tesla/config_flow.py", line 157, in validate_input
    (config[CONF_TOKEN], config[CONF_ACCESS_TOKEN]) = await controller.connect(
  File "/usr/local/lib/python3.8/site-packages/teslajsonpy/controller.py", line 268, in connect
    cars = await self.get_vehicles()
  File "/usr/local/lib/python3.8/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/teslajsonpy/controller.py", line 357, in get_vehicles
    return (await self.__connection.get("vehicles"))["response"]
  File "/usr/local/lib/python3.8/site-packages/teslajsonpy/connection.py", line 78, in get
    return await self.post(command, "get", None)
  File "/usr/local/lib/python3.8/site-packages/teslajsonpy/connection.py", line 96, in post
    self.code = await self.get_authorization_code(
  File "/usr/local/lib/python3.8/site-packages/teslajsonpy/connection.py", line 372, in get_authorization_code
    code_url = URL(resp.history[-1].url)
IndexError: tuple index out of range
1 Like