core: Tesla authentication fails
The problem
My Tesla-integration stopped working yesterday without any changes on the Tesla-accout or the home assistant integration.
What is version of Home Assistant Core has the issue?
core-2021.8.2
What was the last working version of Home Assistant Core?
core-2021.8.2
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Tesla
Link to integration documentation on our website
https://www.home-assistant.io/integrations/tesla/
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Logger: homeassistant.components.tesla.config_flow
Source: components/tesla/config_flow.py:172
Integration: Tesla (documentation, issues)
First occurred: 22:46:12 (1 occurrences)
Last logged: 22:46:12
Authentication error: Unable to login with credentials
Additional information
credentials are working on tesla.com. I tried to uninstall integration, restart home assistant, re-install integration. Error occurs again.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 104
- Comments: 67 (20 by maintainers)
Sorry folks, Tesla is coming out of core. We’ll need to maintain it as a custom component. For now, there’s omelhus’s version which requires a 3rd party app to generate tokens and mine which requires some hosts file editing as a workaround. I’ll probably spend time this weekend getting it into the custom_components and HACS as a default.
Workaround for TeslaFi users (or the ones who can obtain auth keys from other similar service):
The result will look like this:
The “me too posts” clutters the thread. Please +1 the original post if you are having this issue.
That said, I will not be working on this for reasons described here.
Alternatively, someone posted a workaround for advanced users who want to manually log in and copy their tokens over. Modifying .storage directly is not recommended so proceed with caution.
It wasn’t an indirect “f*ck off” it was indirect “Not cool”: You pulled me into a conversation. In general, it is unpolite to randomly mention someone and ask for support. This is also documented in our community guidelines.
I don’t own a Tesla, nor have I any idea what is going on. Please don’t tag/mention people @ random.
Thanks 👍
I can take up being a maintainer for the Tesla integration, though I dont know how I would go on doing so. Also I am still on holiday so thatll have to wait a few more days / weeks.
Can maybe @frenck have some from HA core Team take a look at it and help? It seems there is no one capable to take over the role of code owner right now and code is broken for this official integration.
I guess it wasn’t clearly stated when I first responded to this thread. I have a custom component for Tesla in HACS that doesn’t have the login issue. So if you can’t wait for an official fix and can’t do the work around, you can use that instead. It’s a drop in replacement since it uses the same underlying ids. It’s probably lower quality since it’s not reviewed by the HA team but I also put features (e.g. energy sensor) in there before here.
Do not post bug reports for it here though.
I need this to be solved, all my automations are broken 😢
Thanks @zabuldon for your help getting this integration started. Do you want to be removed from
codeownerssince it’s hard for you to support it now? It also might help if people notice the list of owners has lost people. One thing that’s been discussed is that HA could show the health of integrations by looking at number of active codeowners. I don’t know what happened to that initiative though.Please open a new issue if you’re having a problem and I can look at it. I spent a lot of time looking at the algorithm with other people and tested it across my own use case of 3 separate Teslas till we found 11 minute as a good sweet spot. I’ve also pushed individual users who want more frequent data precisely because I’m concerned about vampire drain for the majority of users. You’re free to edit the documentation as you want to make it better since this is a community effort. I know at least one person who configured their HA to stop updates for a car if Teslamate indicated it was trying to let it sleep. But I don’t use it so don’t know the automation.
Welcome aboard @BreakingBread0 and thanks. As mentioned in teslajsonpy, I can push out your changes in that API pretty quickly and can help explain where I think you’ll need changes. I will also review your changes here as that will also help unstick the PR queue. The complexity for the fix is the fact you’ll need a process that will detect if the captcha shows up and also if the MFA shows up. I see it as at least 3 stages in the config flow, but you may be able to simplify it. I’m on the HA discord if you want to chat.
If you decide to avoid the login and just allow tokens, that may avoid the complexity as you have outsourced the login to the other apps but the PR may be rejected since no other integrations do that. It’d probably worth raising in Discord before you try the token method.
I would not suggest doing both methods unless you want to take on the complexity of two login paths.
@zabuldon: Quality engineer here who can read logs and edit files. Happy to help test changes through the standard update process for HA, but due to work I don’t have the spoons right now to build anything with patches and deploy onto my local instance.
Mostly I think just providing fields to enter in API tokens will give most of the commenters here a work around avenue to stop “me tooing” on this ticket. API tokens can be obtained through Tesla Tokens on Android and Auth app for Tesla on iOS, no fiddling with JSON required.
I don’t understand how some of my other Tesla 3rd party tools sidestep captcha, I believe Teslamate is in that bucket but I could be wrong.
One major problem with the HA’s Tesla integration (and many many other 3rd party integrations) is the refresh rate constantly waking up the car which turns into a vampire drain on the battery over night, as described in the docs. Teslamate is very intelligent on when it should or shouldn’t pole data in order to avoid vampire drain, and even documents how it should be used in parallel with the HA Tesla integration (directing the use to extended out the wait before next refresh in HA). Would it be ok to edit the HA doc to provide a link to Teslamate’s documentation regarding this to give the user another option?
That or just let us put in the token manually would work too.
No. Tesla added a captcha.
Still an issue with 2021.8.4
Yep, I’ll see what I can do. 👍
Maybe the config flow UI should be changed to only accept the refresh token then, as username and password is unlikely to ever work again?
Hello guys, As I can see there is a huge discussion around Tesla component. Let me explain why I’m not contributing this anymore. I don’t have Tesla anymore, so it is not easy to support this whiothout having a cat, so if someone ready to help with troubleshooting I can spend some time to work on the integration again, but I’m not sure if that issue not occurs again in the future. Ideal solution in this case to find out a new maintainer.
Can we pass the captcha through Home Assistant to the user when getting the API keys?
I guess this doesn’t work if I’ve removed the integration already? I can’t re-add it because it gives me the error upon attempting to do so.
Expected as much, this was just for testing. Ill be pushing a change on there that should allow it to work past the initial setup phase today or tomorrow.
Thanks for the update @alandtse. I wish Tesla would properly support third party applications.
As an update, Tesla enabled recaptcha this weekend. This broke my custom component and likely will break it for many other implementations since it requires JavaScript parsing. The most likely solution is the token solution assuming there remains some apps able to generate the refresh token every 45 days.
EDIT: There’s a workaround for my custom component so it’s still a viable option if you understand how to edit your
hostsfile.I have this working as a custom component where I’ve just made password optional and added the refresh token as a fourth option in the config flow.
I’ve just published my custom component at https://github.com/omelhus/tesla_custom_component
To integrate the full captcha-based login to obtain a token, you are free to look at the Postman Collection I linked to above. It’s another Github project and has all of the steps to connect to Tesla’s authentication endpoint, generate the appropriate codes / strings, pull up the Tesla authentication UI with captcha, and obtain the access token and refresh token.
https://github.com/jdemeyer1/TeslaAPIThruPostman
I don’t think that it is necessary to remove myself from codeowners as sometimes I’m still checking issues and PRs. Please drop me an email @mat1990dj if you ready to help
Okay, even though many of you liked the idea @frenck replied with an indirect “f*ck off” so I no solution from the HA team then ^^
You’ll need a way to generate a new
entry_idbut you can copy my block from above. I just ended up restoring from a backup I had from over a month ago and copying that entry.@bdoooh I had botched up pasting my API keys on my first attempt. Try looking at your logs for any mention of
tesla. You may need to change your default logging level to get more details.@mat1990dj @denisjoshua : The workaround listed in this previous comment worked for me. You can grab your API keys from this app on Android, if you search around there’s a similar app for iOS. If you know how to edit your
configuration.yamlfile directly on your HASS machine, you’re capable of making this work around go in order to fix your crucial automations.If you need a proper solution, feel free to fix the code and drop a pull request as per the guidelines of this open source project, or wait for a volunteer dev to get to this issue. Otherwise that workaround does indeed work.
Please test this branch to log in with your tesla refresh and access tokens. (Username = refresh token, Password = access token). Use this app to obtain both of those tokens. If that works I will create a new config flow option to use your refresh token to login. (The access token can be generated by itself once this fix gets merged to teslajsonpy)
Keep in mind that this is not a fix for production use, this is just for texting and WILL break.
It seems every other time I upgrade HA, the Tesla integration breaks 😕