dbweb-ch / ioBroker.tesla-motors

ioBroker Adapter for Tesla Motors Cars
MIT License
11 stars 9 forks source link

Tesla: No response #78

Closed bluppdiwupp closed 3 years ago

bluppdiwupp commented 3 years ago

after the update with 5.1:

Could not retrieve token, Error from Tesla: No response

i don't have TFA.

dbweb-ch commented 3 years ago

Did you try it a couple of times? Sometimes the tesla server does not respond for a while....

bluppdiwupp commented 3 years ago

yes, many times. No issue with the homepage or app.

SamLowrie commented 3 years ago

Same here, no TFA as-well, same "Tesla: no response" error:

hombach commented 3 years ago

same here: "Could not retrieve token, Error from Tesla: No response" perhaps we should wait some hours - tesla is changing a lot right now because of upcoming new software for Model S/X refresh....

and-web commented 3 years ago

This affects me, also. Downgraded to 0.4.2 to restore a working adapter state.

My observations for troubleshooting:

hombach commented 3 years ago

I also get the captcha - a "good" one, also hard for me.... Inside the account are also changes, my old cars aren't viewable any more, same for tesla shop orders.

dbweb-ch commented 3 years ago

@hombach yes this seems to be the issue, see: https://github.com/mseminatore/TeslaJS/issues/247 and https://github.com/timdorr/tesla-api/discussions/390 and https://twitter.com/ycorsair/status/1398160096325111808?s=20

as this adapter is based on TesjaJS, there is not much that I can do to resolve this. Either someone finds a way to work around this captcha, but I am sure tesla will find another way to reject us, or Tesla finally generates an official api. You can try to ask tesla support for this feature, if we are enough people tesla might sees that this is needed.

ChrisPrefect commented 3 years ago

Same for me. Adapter does not work anymore. It worked before. Can we downgrade somehow?

ChrisPrefect commented 3 years ago

I can't enter a token directly in the adapter settings. Is this blocked somehow? How can the input fields be activated?

dbweb-ch commented 3 years ago

This is blocked, yes, as the adapter is supposed to get the token by itself. You can't downgrade, as said, tesla itself has changed their login process, this has nothing to do with the version of this adapter and will happen with any version.

hombach commented 3 years ago

Tesla removed the captcha - Adapter is working again!!!

bluppdiwupp commented 3 years ago

doesn't work: Could not retrieve Data from the Car! Response: Error response: 408

aski71 commented 3 years ago

Same here. :-( Everything still worked well last week.

aski71 commented 3 years ago

I’m using 2FA. I was able to retrieve a new token when entering a current OTP and then requesting a new token. I was able to store it. Since then I‘m also getting: Could not retrieve Data from the Car! Response: Error response: 408

dbweb-ch commented 3 years ago

Can you try to wake up the car first by using the Tesla App on your phone and then try to get data with the adapter?

DanielWeeber commented 3 years ago

Adapter still showning me "no response" although Tesla deactivated the captcha

dbweb-ch commented 3 years ago

It looks like this is pretty random and has nothing to do with the adapter. I have two installations of the adapter and both work with the newest version. But on one of them I was not able to get a token for a while. To say, I can't test it without 2 factor authentication, but as the adapter is pretty often installed I assume there would might be more users having troubles. That would mean you have to try to authenticate a couple of times until you get a token.

Btw. I am curently testing Version 0.5.3 which has a couple of improvements with requesting data and the sleep function, will merge it into master in a couple of days.

DanielWeeber commented 3 years ago

It's broken for since a few weeks for me. I tried about 50 times min. :( Will try to use 0.5.3

dbweb-ch commented 3 years ago

strange. I just updated another test instance to 0.5.3 and it worked with the first try. Do you have 2FA or not?

DanielWeeber commented 3 years ago

No 2FA.

dbweb-ch commented 3 years ago

ok, then this might really does not work anymore. I will check if I can get a hand on a tesla without 2FA, one of my colleges has one.

Or you could just use 2FA, for such an expensive thing like a car I would suggest this anyway ;)

DanielWeeber commented 3 years ago

I just logged in to tesla.com. It notified me that my account is locked due to too many failed authentications (maybe because of the tesla adapter when captcha was activated). Strangely my tesla app was working all the time, hence I did not notice that my account was locked. I just changed the password, I think/hope it will work again. Will try later today.

dbweb-ch commented 3 years ago

As long as the app has a valid token, it can still get data even if the account is locked.

DanielWeeber commented 3 years ago

I just tried, is working fine now. Account locked was the problem.

aski71 commented 3 years ago

My issue might indeed be that the car is in an underground garage with no access currently. Will know latest tomorrow. Nevertheless Token Refresh seems to require to type in a new OTP at the time of refresh when 2FA is enabled.

dbweb-ch commented 3 years ago

I am not sure about this, we will see if it needs a new OTP. But the "refresh"-Token wouldn't make much sense in that case, as it is usually there to prevent from user interaction but still being able to refresh a token. Also, the Tesla App would require a new OTP every time the token refreshes, I don't think I've ever had to reenter the OTP since I activated 2FA. I will see as soon as my current token needs to be refreshed next time.

aski71 commented 3 years ago

All I can say: It is working again, now that I have the new token. And I was only able to refresh the token manually. And when I wanted to refresh it, I always received „No response“. Only when I unchecked 2FA, checked it again, entered a current OTP and did a token refresh then, the refresh operation succeeded.

aski71 commented 3 years ago

I‘ll keep observing what will happen should troubles reoccur.

BerniZindel commented 3 years ago

I had the same issue (no 2FA) - the solution for me was to re-enter the password and refresh the token manually (v.0.5.2)

aski71 commented 3 years ago

Interesting effect today: Today I had hundreds of log messages: 2021-07-15 10:41:56.529 | warn | Invalid answer from Vehicle request. Error: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"] -- | -- | --

Needed to obtain a new token using 2FA with a current OTP. Then it worked again. Even though the old token was not yet expired.

PanRe commented 3 years ago

Interesting effect today: Today I had hundreds of log messages: 2021-07-15 10:41:56.529 | warn | Invalid answer from Vehicle request. Error: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"] -- | -- | --

Needed to obtain a new token using 2FA with a current OTP. Then it worked again. Even though the old token was not yet expired.

I had the same issue but without 2FA and without saved credentials... I had to restart the iobroker tesla instance to obtain a new valid token (while the old one should have been still valid). Trying to get a new token before i restarted the instance always ended in the same error message (26917) Invalid answer from Vehicle request. Error: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"] (26917) Could not retrieve Data from the Car! Response: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"] While this error was active, there really were "invalid" characters shown in the former received token. Multiple characters were displayed by a [x] like symbol! Before this came up, it worked flawlessly for weeks.

OS: Raspberry Pi OS Lite on a Raspi Zero W, Node.js: v12.22.3, NPM 6.14.13

aski71 commented 3 years ago

Same behaviour again today: `

tesla-motors.0 2021-07-31 19:29:21.662 warn Invalid answer from Vehicle request. Error: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Authorization"]

` This message kept repeating continuously. The token should have been valid until September. I had to manually obtain a new token using 2FA with a current OTP. Then it worked again.

Just like 16 days ago.

dbweb-ch commented 3 years ago

This might has something to do with https://github.com/mseminatore/TeslaJS/pull/220 , as soon as this is merged with teslajs and release, I will update teslajs. In meantime, I've enabled the manual input of the token, you should get it from the latest version 0.5.4.

aski71 commented 3 years ago

Had the invalid character in header error again today. Updated to 0.5.4. With 0.5.4 it's now completely broken. With 0.5.3 I was formerly able to retreive a new token with a new OTP. With 0.5.4 I can not even do that anymore: No response. :-( Tried to downgrade to 0.5.3 again but did not work. So I uninstalled completely and reinstalled. Again 0.5.4. Again: No response. :-( Tried to manually enter Tokens via Auth for Tesla: Does not work, because the save button is grayed out. :-( So the adapter became completely unusable for me. :-(((

nachtschatt3n commented 3 years ago

This might has something to do with mseminatore/TeslaJS#220 , as soon as this is merged with teslajs and release, I will update teslajs. In meantime, I've enabled the manual input of the token, you should get it from the latest version 0.5.4.

I did that as well but this strange encryption kicks in. Also you need the vehicle so I arranged the code a little to get the vehicle but its not working yet. Maybe I continue tonight at https://github.com/nachtschatt3n/ioBroker.tesla-motors/commit/52b5e27cf8b43f94d1985f60ceef08e0a326b112

adultano commented 3 years ago

Hi. I will describe here what steps I have taken to make the Tesla adapter in iobroker working again. First of all it is important to know that I will not take any responsibility whatsoever if it comes to system issues and/or fraudelent activitites. I am a private user with a little bit of coding knowledge. I have nothing to do with neither the coding of the tesla adapter nor teslafi or teslapy. This workaround is based on two steps. 1) you need to obtain the tokens either through teslafi.com or teslapy (python module on github). 2) you need to manipulate the code in iobroker -> tesla adapter to enable the token fields and the save & close button. I run iobroker on a rapberry 4 and another one on win10. To manipulate the code, I used google Chrome. The same approach might be feasible through other browser, but I do not know how these work. 1a) Obtain token through teslafi.com -This should be self-explaining. There is a 14days trial period. You will submit your login-details, the 2FA code if necessary and you'll be prompted with the captcha. Afterwards you'll receive the access and refresh token which you'll need. 1b) Obtain token through teslapy -This is a bit more complex. You need python and telsapy from github. You'll also need to change the Init__.py file as discussed on github under issues, issue #29. You will submit again your credentials and receive the captcha through the standard defined browser on your system. Your tokens will then be stored in cache.json in the same folder as you save your python script to obtain the tokens. As said, this is a more complex approach and you might need to play around a bit.

2) In chrome (or any other browser, go to the tesla instance in iobroker. Enter email address and password. Don't tick 2FA, no matter if you have it or not. Next right click on the token field -> inspect. The debug window will be added on the right. You'll see that the field is marked as readonly="readonly". Double click on read-only and delete this. Same for the refresh token tab. Last, right click on the Save and Close button -> inspect, click the little arrow and change in the second line (btn-save-close) from disable to enable. Now you're all setup and should b able to copy paste the token and the refresh token from 1a or 1b and click the save & close button. Ideally the car is not asleep when you do this, but in theory it should wake it if it still is.

I did not bother adding the expiry time. You'll probably notice that in 3 months it wont work anymore. If the problem with captcha persists by then I suppose we can do the same steps again and update the tokens manually.

I attached a couple of printscreens which might help with the debug part in 2. I also added a printscreen of my python script which stores the tokens in cache.json. inspect

remove_readoly

updatedTokens

buttonEnabled

updatedSaveButton

pythonScript

Ideally the developers of the adapter give the user the flexibilty in a next release, to either let the adapter obtaining the tokens automatically or that the user can provide this on his own.

I hope above steps work for other users too. Again, I do not take any responsibility especially for the generation of the tokens. You are submitting your login details to a third party which always poses a certain risk which you need to decide for yourself if you are willing to take it. Any feedback will be appreciated.

Lastly a big thanks to the developpers of the Tesla adapter! And should I have violated any rules with my post, please let me know or delete it. I am just trying to help out other users with thisworkaround.

Thanks

aski71 commented 3 years ago

Thanks for the workaround! I tried it with a token pair I obtained via Auth For Tesla app. Did not work, unfortunately. Maybe it is because my car is not reachable right now. Will try again.

adultano commented 3 years ago

Thanks for the feedback. Ill try auth for tesla too later and let you know

adultano commented 3 years ago

I think authfortesla might not work - whilst the acces token looks ok (qts-xxxxxx..) the refresh token seems to be of a different type. The one from my approach has 64 digits, the one from the app has a gazillion. Maybe try it with teslafi.com and check again.

BerniZindel commented 3 years ago

thanks @adultano - followed your steps and used teslapy. Had to insert code as mentioned here in this commit: https://github.com/tdorssers/TeslaPy/commit/ebcef529f9a7754d3b025caef8721327cf2cb3a6

edit: installed via pip - there is the fix not implemented yet

adultano commented 3 years ago

thanks @adultano - followed your steps and used teslapy. Had to insert code as mentioned here in this commit: https://github.com/tdorssers/TeslaPy/commit/ebcef529f9a7754d3b025caef8721327cf2cb3a6

edit: installed via pip - there is the fix not implemented yet

Thanks - does this mean your connected to your car again and this workaround worked for you too?

BerniZindel commented 3 years ago

thanks @adultano - followed your steps and used teslapy. Had to insert code as mentioned here in this commit: tdorssers/TeslaPy@ebcef52 edit: installed via pip - there is the fix not implemented yet

Thanks - does this mean your connected to your car again and this workaround worked for you too?

yes - everything works fine again.

adultano commented 3 years ago

thanks @adultano - followed your steps and used teslapy. Had to insert code as mentioned here in this commit: tdorssers/TeslaPy@ebcef52

edit: installed via pip - there is the fix not implemented yet

Thanks - does this mean your connected to your car again and this workaround worked for you too?

yes - everything works fine again.

Glad I wasnt making things up then. Appreciathe feedback.

and-web commented 3 years ago

Hi. I will describe here what steps I have taken to make the Tesla adapter in iobroker working again.

Thanks @adultano, you made my day. Well, you made my month! Thank you so much.

I obtained the token via the iOS app "Auth for Tesla", used Chrome to make the save button clickable (the input fields are already writable since 0.5.4), entered the two tokens, saved - and it worked again, after 12 days of abstinence. Feels good man!

So proud of you @adultano and also a big shout out to @dbweb-ch, this here means a lot to me. Thank you!

dbweb-ch commented 3 years ago

been working a couple of hours on this and released a new version 0.5.5. I hope this time I've tested it enough...

You are now able to enter the token manually, then retrieve the car info, store that stuff all together and the adapter works. I've also tested the automatic token refresh which was not working anymore due to a double-encryption issue, this was causing the "ERR_INVALID_CHAR" error. I hope now it works well and you can use the adapter again. I still don't know why I can't get any token but this might has something to do with an error of the teslajs-API, need to dig deeper into that, but at least with the manual token input you now have a workaround.

And thanks @adultano for your help delivering a workaround in meantime.

dbweb-ch commented 3 years ago

Ah and btw.: I've also not been able to get a token with the adapter. I've used the php script which is mentioned on https://www.teslafi.com/ and is posted here: https://github.com/timdorr/tesla-api/discussions/362

I could put that script onto my server but then you would need to trust me as credentials are sent to the server to get the token (serverside script), but this is anyway an issue you will have with most of the services that get you a token (including teslafi). Btw.: If you don't use 2FA I HIGHLY recommend it, especially when you get tokens from any other source than from your own server / iobroker. Someone could easy steal your credentials and as tesla is telling you where it is located, steal your car. Or just observe you when you leave your house and break in...or whatever a criminal mind would do.

BerniZindel commented 3 years ago

Ah and btw.: I've also not been able to get a token with the adapter. I've used the php script which is mentioned on https://www.teslafi.com/ and is posted here: timdorr/tesla-api#362

I could put that script onto my server but then you would need to trust me as credentials are sent to the server to get the token (serverside script), but this is anyway an issue you will have with most of the services that get you a token (including teslafi). Btw.: If you don't use 2FA I HIGHLY recommend it, especially when you get tokens from any other source than from your own server / iobroker. Someone could easy steal your credentials and as tesla is telling you where it is located, steal your car. Or just observe you when you leave your house and break in...or whatever a criminal mind would do.

Thank you for your incredible work, @dbweb-ch . I'm not sure how they automatically solve the capture but I guess, for me was the possibility to solve it manually the breaking point....

adultano commented 3 years ago

been working a couple of hours on this and released a new version 0.5.5. I hope this time I've tested it enough...

You are now able to enter the token manually, then retrieve the car info, store that stuff all together and the adapter works. I've also tested the automatic token refresh which was not working anymore due to a double-encryption issue, this was causing the "ERR_INVALID_CHAR" error. I hope now it works well and you can use the adapter again. I still don't know why I can't get any token but this might has something to do with an error of the teslajs-API, need to dig deeper into that, but at least with the manual token input you now have a workaround.

And thanks @adultano for your help delivering a workaround in meantime.

Thank you very much @dbweb-ch ! This works flawlessly so far; the login screen is now exactly how I imagined it should look like with the possibility to provide own tokens. Simply perfect. Works awesome. I really highly appreciate the work you put into this! Hero!

aski71 commented 3 years ago

Manual input of tokens now works for me as well! Thanks!! Highly appreciated!

and-web commented 3 years ago

Unfortunately this stopped working once again. :-(

Did they change the token format? The access token now starts with "eu-", where formerly it started with "qts-". Could this be the reason?

Behaviour is:

Could it be that the adapter refuses to accept access tokens starting with "eu-"? Due to the fact that it successfully detects the token's expiration date and also due to the fact that it receives the vehicle parameters, there seems to be at least limited functionality with the refreshed token.