Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
151 stars 32 forks source link

Auth breaks down mutiple times per day #251

Open petrsimunek opened 4 hours ago

petrsimunek commented 4 hours ago

I have been using the volvo2mqtt for some time, and it worked flawlessly. But today the plugin get unauthorized every couple hours, and I have to reenter the OTP over and over again.

Logs below.

Oct 26 16:47:28 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:47:29 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 16:49:29 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:49:30 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 16:51:30 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:51:32 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 16:53:32 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:53:34 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 16:55:34 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:55:42 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 16:57:42 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:57:43 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 16:59:43 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 16:59:45 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:01:45 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:01:46 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:03:46 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:03:47 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:05:47 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:05:49 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:07:49 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:07:50 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:09:50 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:09:52 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:11:52 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:11:53 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:13:53 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:13:55 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:15:55 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:15:56 volvo2mqtt [106] - INFO: Mqtt update done. Next run in 120 seconds. Oct 26 17:17:56 volvo2mqtt [106] - INFO: Sending mqtt update... Oct 26 17:17:56 volvo2mqtt [106] - INFO: Refreshing credentials Oct 26 17:17:56 volvo2mqtt [106] - INFO: Starting login with OTP Traceback (most recent call last): File "/volvoAAOS2mqtt/main.py", line 16, in <module> update_loop() File "/volvoAAOS2mqtt/mqtt.py", line 295, in update_loop update_car_data() File "/volvoAAOS2mqtt/mqtt.py", line 336, in update_car_data state = volvo.api_call(entity["url"], "GET", vin, entity["id"], force_update) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/volvoAAOS2mqtt/volvo.py", line 465, in api_call refresh_auth() File "/volvoAAOS2mqtt/volvo.py", line 201, in refresh_auth authorize(renew_tokenfile=True) File "/volvoAAOS2mqtt/volvo.py", line 77, in authorize response = send_otp(auth_session, response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/volvoAAOS2mqtt/volvo.py", line 168, in send_otp raise Exception(message["details"][0]["userMessage"]) Exception: This passcode is invalid or has expired.

Ilpo55 commented 3 hours ago

Same here. Is it API server issue....

poppyfields commented 3 hours ago

Same for me - started about 2 hours ago - new OTP never recognised

Dielee commented 3 hours ago

Yes, you found a bug. Already fixing ;)

Dielee commented 3 hours ago

So, I don't know why your credential refresh isn't working, but I have added more logging to bring some light into the dark. And you found a bug, which appears if the OTP auth is used more than once while the addon is runing. Fixed by v1.10.3.

nsimons commented 2 hours ago

Would it be possible to change the OTP process so that it does not spam SMS' to your phone when the addon loses the authentication data? If you are not at home with access to your HA instance, then you are not able to stop it.

Some ideas:

Dielee commented 2 hours ago

Would it be possible to change the OTP process so that it does not spam SMS' to your phone when the addon loses the authentication data? If you are not at home with access to your HA instance, then you are not able to stop it.

Some ideas:

  • start the OTP flow once (so that one SMS is sent), if no action taken from the user then give up gracefully and wait
  • alert/warning in HA that credentials are missing
  • possibility to start the OTP process manually, some button/boolean input entity (?)

Maybe I will add an option to change the otp behavior. For now, the addon will restart, if the auth wasn't successful.

LaurentB6928 commented 25 minutes ago

Just installed the latest version but it did fix anything for me. I noticed this warning in the log file: Oct 26 20:59:31 volvo2mqtt [106] - WARNING: Refreshing credentials failed!: 400 Message: {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"} I didn't change anything in the config data, VCC API Key is the same since the beginning

Dielee commented 3 minutes ago

Just installed the latest version but it did fix anything for me. I noticed this warning in the log file: Oct 26 20:59:31 volvo2mqtt [106] - WARNING: Refreshing credentials failed!: 400 Message: {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"} I didn't change anything in the config data, VCC API Key is the same since the beginning

This is another issue. Please delete your .token file and restart the auth.