Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
125 stars 25 forks source link

Updates do not resume after adding OTP token #193

Closed canoben closed 1 month ago

canoben commented 1 month ago

I followed the instructions for version 1.9 to add the OTP token that Volvo sent me this morning at 10:30. Since then, there have been no further updates and it seems like the integration does no longer run. Here are the last lines of the log file of volvo2mqtt: May 27 10:30:18 volvo2mqtt [107] - INFO: Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 12/15 May 27 10:30:23 volvo2mqtt [107] - INFO: Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 13/15 May 27 10:30:28 volvo2mqtt [107] - INFO: Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 14/15 Traceback (most recent call last): File "/volvoAAOS2mqtt/main.py", line 15, in <module> authorize() File "/volvoAAOS2mqtt/volvo.py", line 71, in authorize response = send_otp(auth_session, response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/volvoAAOS2mqtt/volvo.py", line 155, in send_otp raise Exception ("No OTP found, exting...") Exception: No OTP found, exting... s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

I only rectified the OTP situation now (8 hours later), but whatever I try (restart the integration, restarting HA), no further log entries are produced and the dashboard shows all the sensors as not available.

Dielee commented 1 month ago

You have to fill in the otp code immediately after the addon starts, not a few hours later.

canoben commented 1 month ago

Well, as I missed it, what can I do now?

micvdh commented 1 month ago

You have to fill in the otp code immediately after the addon starts, not a few hours later.

although following the instructions, setting up the OTP code in the text value, I still systematically end-up with the following (running version 1.9.1) :

May 27 19:57:36 volvo2mqtt [106] - INFO: Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 23/24 Traceback (most recent call last): File "/volvoAAOS2mqtt/main.py", line 15, in authorize() File "/volvoAAOS2mqtt/volvo.py", line 73, in authorize response = send_otp(auth_session, response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/volvoAAOS2mqtt/volvo.py", line 157, in send_otp raise Exception ("No OTP found, exting...") Exception: No OTP found, exting... s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped

golf1025 commented 1 month ago

Same here. Also not clear how the text.volvo_opt should look like after pasting opt as per instruction step 6. Should it read text.xxxxx ?

Dielee commented 1 month ago

Maybe HA is a bit buggy firing the otp input. Please try to post your otp manually to this topic via mqtt:

volvoAAOS2mqtt/otp_code

micvdh commented 1 month ago

volvoAAOS2mqtt/otp_code

It worked indeed, calling MQTT publish service solved the issue

service: mqtt.publish data: topic: volvoAAOS2mqtt/otp_code payload: XXXXXX

Thanks, looking forward for some easier way, but already a great step ahead !

Thanks !!!

Dielee commented 1 month ago

Yes, thanks for testing. This is indeed an HA bug... I will think about a better solution tomorrow.

canoben commented 1 month ago

Before reading the solution above, I reinstalled the VOC plugin (after removing it), but now I'm unable to re-add my car.

Edit: I used a backup of HA and now the integration is working again, although I'm still on version 1.8 of the plug-in.

Pieter1979 commented 1 month ago

HI, first of all thanks for all your efforts! I have a small question: I have the latest version but I don't find the entity ID text.volvo_otp. I rebooted, installed all the latest versions. I only see Volvo2Mqtt Update. I receive the OTP password on mail, so the connection is made but I don't find the place where I can place it. I work with the Mosquitto broker.

thanks!

Dielee commented 1 month ago

Please try to post your otp manually to this topic via mqtt:

volvoAAOS2mqtt/otp_code

ahlburg commented 1 month ago

I can see in the logg that I actually was able to change the code but the second after it automatically gets reset to 00000 by some damn process somewhere... Any ideas? Catch 22, I change the code and when I start the integration I get a new email from Volvo with a new code... If I try to add the "latest" code from Volvo email the system changes it back the second after to "000000"...

If you got it working, how did you do? Tried uninstalling/reinstalling but I never see "OTP missing..." only "Exception: This passcode is invalid or has expired."

Volvo OTP ändrades till 000000 19:16:43 - För 9 minuter sedan Volvo OTP ändrades till 712139 19:16:43 - För 9 minuter sedan Volvo OTP ändrades till 000000 19:09:31 - För 16 minuter sedan

micvdh commented 1 month ago

Not sure if it's still required since the upgrade to 1.9.2 today, but here is how to publish new value manually to mosquito topic. This is how I solved my issue yesterday (running on 1.9.1)

image

ahlburg commented 1 month ago

OK, maybe something was broken with the update because that doesn't work now!

ahlburg commented 1 month ago

No ideas what's forcing the value back to 000000 as soon as it is changed (to somethiing else) via mqtt.publish?

Skärmavbild 2024-05-29 kl  07 59 03
Pieter1979 commented 1 month ago

That worked. Thanks

Op 28 mei 2024 om 08:11 heeft Linus Dietz @.***> het volgende geschreven:



Please try to post your otp manually to this topic via mqtt:

volvoAAOS2mqtt/otp_code

— Reply to this email directly, view it on GitHubhttps://github.com/Dielee/volvo2mqtt/issues/193#issuecomment-2134417344, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BIYU5O4U3YKTXMG2JFUWYV3ZEQNYLAVCNFSM6AAAAABILPVIFOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZUGQYTOMZUGQ. You are receiving this because you commented.Message ID: @.***>

Peacem4kr commented 1 month ago

Hi, i have this integration active for months now. I updated HA to 2024.05, and i think i also updated volvo2mqtt to 1.9.2, and some other addons as well tbh. Restarted HA and volvo stopped working, noticed in the addon log the same error as mentioned above "missing otp".

I tried to execute the above aswell: image Is this even correct what i am doing here please and is the OTP even my volvo app password then?

I also checked the state: image

Is also 000000 like Ahlburg.

Any idea what i can do please?

Thank you!

ahlburg commented 1 month ago

I believe this must be a bug because EVERY time I start/restart the addon, the value of "text.volvo_otp" changes to "000000". Doesn't matter if I successfully change the value to something else before (or after) starting the addon...

Dielee commented 1 month ago

I believe this must be a bug because EVERY time I start/restart the addon, the value of "text.volvo_otp" changes to "000000". Doesn't matter if I successfully change the value to something else before (or after) starting the addon...

Do you have to enter the otp every time the addon restarts ?

Ilpo55 commented 1 month ago

I updated from version 1.8.27 to version 1.9.2 and it is working also after restart OK. I used "Paste your OTP into the text entity and press Enter" without any problems.

ahlburg commented 1 month ago

I believe this must be a bug because EVERY time I start/restart the addon, the value of "text.volvo_otp" changes to "000000". Doesn't matter if I successfully change the value to something else before (or after) starting the addon...

Do you have to enter the otp every time the addon restarts ?

I have never been able to try that because when I try to set the text.volvo_otp, the addon tries to start, changes the value to 000000 and then complains about wrong passcode and dies... If I then set the otp to value sent in email and then tries againg to start the addon changes the value back på 000000 and then dies with same error...

ahlburg commented 1 month ago

I updated from version 1.8.27 to version 1.9.2 and it is working also after restart OK. I used "Paste your OTP into the text entity and press Enter" without any problems.

Did you set the OTP before starting the addon?

Peacem4kr commented 1 month ago

Not sure what is happening for me then, maybe its not the update but something else, not sure tbh, but its the same error :) I was hardly able to set this up initially, so was happy once this worked :) Is there something i can test?

Is OTP the volvo app password actually? Where can i find: "Paste your OTP into the text entity and press Enter" i see this: image

Ilpo55 commented 1 month ago

I updated from version 1.8.27 to version 1.9.2 and it is working also after restart OK. I used "Paste your OTP into the text entity and press Enter" without any problems.

Did you set the OTP before starting the addon?

First I started the add on and then I entered the code while add on was running.

ahlburg commented 1 month ago

Not sure what is happening for me then, maybe its not the update but something else, not sure tbh, but its the same error :) I was hardly able to set this up initially, so was happy once this worked :) Is there something i can test?

Is OTP the volvo app password actually? Where can i find: "Paste your OTP into the text entity and press Enter" i see this: image

The "OTP" shoul be sent to your email address from Volvo when you start the addon...

Peacem4kr commented 1 month ago

kinda thought that, but i didnt receive any emails. Where did you define the email address to use?

Ilpo55 commented 1 month ago

Not sure what is happening for me then, maybe its not the update but something else, not sure tbh, but its the same error :) I was hardly able to set this up initially, so was happy once this worked :) Is there something i can test? Is OTP the volvo app password actually? Where can i find: "Paste your OTP into the text entity and press Enter"

Setting, Devices and Services, Entities

votp

ahlburg commented 1 month ago

I updated from version 1.8.27 to version 1.9.2 and it is working also after restart OK. I used "Paste your OTP into the text entity and press Enter" without any problems.

Did you set the OTP before starting the addon?

First I started the add on and then I entered the code while add on was running.

For me, the addon quits because the otp-code is wrong so I never have the chance to add while the addon is running. If I try to set it to restart autimatically I get one email from Volvo everytime it restarts with a new code...

ahlburg commented 1 month ago

kinda thought that, but i didnt receive any emails. Where did you define the email address to use?

Your Volvo-ID includes your email-address... https://developer.volvocars.com/

Peacem4kr commented 1 month ago

kinda thought that, but i didnt receive any emails. Where did you define the email address to use?

Your Volvo-ID includes your email-address... https://developer.volvocars.com/

I see, that is my gmail account. nothing received when starting the addon, never have tbh

In the addon config is a different email address tho, could this be an issue? image

ahlburg commented 1 month ago

Everytime I try to start the addon: Traceback (most recent call last): File "/volvoAAOS2mqtt/main.py", line 15, in authorize() File "/volvoAAOS2mqtt/volvo.py", line 73, in authorize response = send_otp(auth_session, response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/volvoAAOS2mqtt/volvo.py", line 164, in send_otp raise Exception(message["details"][0]["userMessage"]) Exception: This passcode is invalid or has expired. s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

So obviously no chance to set value of otp while running... I also see that the value is set back to "000000" in the log for otp: Loggbok Visa mer 29 maj 2024 Ändrades till 000000 13:03:06 - För 2 minuter sedan Ändrades till 123456 13:03:05 - För 2 minuter sedan Ändrades till 000000 13:01:55 - För 3 minuter sedan Ändrades till 123456

ahlburg commented 1 month ago

kinda thought that, but i didnt receive any emails. Where did you define the email address to use?

Your Volvo-ID includes your email-address... https://developer.volvocars.com/

I see, that is my gmail account. nothing received when starting the addon, never have tbh

In the addon config is a different email address tho, could this be an issue? image

I also use Google-account for Volvo (authentication) but have a different email-address for messages. Works fine...

Peacem4kr commented 1 month ago

So obviously no chance to set value of otp while running... I also see that the value is set back to "000000" in the log for otp:

as this is the same behavior as me just putting in my volvo password (in other words -> a faulthy, not recognized password), then i restarted and the pw is back to 00000. Maybe yours is just not recognized?

ahlburg commented 1 month ago

So obviously no chance to set value of otp while running... I also see that the value is set back to "000000" in the log for otp:

as this is the same behavior as me just putting in my volvo password (in other words -> a faulthy, not recognized password), then i restarted and the pw is back to 00000. Maybe yours is just not recognized?

Correct, that is my issue; the addon changes the value of "otp" to "000000" and dies before I'm able to set the new value of otp that is sent from Volvo... But my configuration works fine, I receive email from Volvo when I start the addon and I can use the Sandbox and everything at Volvos developer site...

Peacem4kr commented 1 month ago

For me, i just dont get why suddenly it starts asking for OTP when the addon has been in use for ages. I also never received any emails about OTP, or any email for that matter while i was setting this up, it just kind a worked. I feel (could be wrong) that i have not changed anything that could impact such behavior.

Can you/we fully resinstall this addon and would that be of any help?

Ilpo55 commented 1 month ago

For me, i just dont get why suddenly it starts asking for OTP when the addon has been in use for ages.

Do you have Auto update ON? That could be the reason.

ahlburg commented 1 month ago

For me, i just dont get why suddenly it starts asking for OTP when the addon has been in use for ages. I also never received any emails about OTP, or any email for that matter while i was setting this up, it just kind a worked. I feel (could be wrong) that i have not changed anything that could impact such behavior.

Can you/we fully resinstall this addon and would that be of any help?

I have done that without any difference... From what I understand the new version needs "OTP" because of changes in Volvos API authentication. In your case you need to find out how to get the emails from Volvo. Maybe it will work for you if you put in the correct OTP. But if your addon also chenges the value back to "000000" and crashes in one second you will have the same problem as I do...

Peacem4kr commented 1 month ago

Ok, need to rephrase due too my stupidity.. Its working now, i was actually receiving a code... but on my volvo app user account, not on my volvo dev account. But as you are receiving emails, this would not be applicable to you.

i fixed my issue with the solutions provided above.

What i did: Started the addon: volvo2mqtt Opened: Settings - Devices & Services - Entities Searched for: OTP Open the entity and provided the newly received code + enter, and close

Side remark, first time i did this.. my addon just stopped and i noticed the code changed back to 0. Did the same, but a bit faster. Code remains the same now..

All this is without any restarts.

ahlburg commented 1 month ago

Ok, need to rephrase due too my stupidity.. Its working now, i was actually receiving a code... but on my volvo app user account, not on my volvo dev account. But as you are receiving emails, this would not be applicable to you.

i fixed my issue with the solutions provided above.

What i did: Started the addon: volvo2mqtt Opened: Settings - Devices & Services - Entities Searched for: OTP Open the entity and provided the newly received code + enter, and close

Side remark, first time i did this.. my addon just stopped and i noticed the code changed back to 0. Did the same, but a bit faster. Code remains the same now..

All this is without any restarts.

OK, lucky you ;-) I have done the exact same thing many times (added the new code within a few seconds) but the addon changes the value to 000000 and crashes (within milliseconds I believe).

Dielee commented 1 month ago

Ok, need to rephrase due too my stupidity.. Its working now, i was actually receiving a code... but on my volvo app user account, not on my volvo dev account. But as you are receiving emails, this would not be applicable to you.

i fixed my issue with the solutions provided above.

What i did: Started the addon: volvo2mqtt Opened: Settings - Devices & Services - Entities Searched for: OTP Open the entity and provided the newly received code + enter, and close

Side remark, first time i did this.. my addon just stopped and i noticed the code changed back to 0. Did the same, but a bit faster. Code remains the same now..

All this is without any restarts.

OK, lucky you ;-) I have done the exact same thing many times (added the new code within a few seconds) but the addon changes the value to 000000 and crashes (within milliseconds I believe).

The addon resets the otp to 000000 only if the OTP mechanism starts. Please share some debug logs.

ahlburg commented 1 month ago

Ok, need to rephrase due too my stupidity.. Its working now, i was actually receiving a code... but on my volvo app user account, not on my volvo dev account. But as you are receiving emails, this would not be applicable to you. i fixed my issue with the solutions provided above. What i did: Started the addon: volvo2mqtt Opened: Settings - Devices & Services - Entities Searched for: OTP Open the entity and provided the newly received code + enter, and close Side remark, first time i did this.. my addon just stopped and i noticed the code changed back to 0. Did the same, but a bit faster. Code remains the same now.. All this is without any restarts.

OK, lucky you ;-) I have done the exact same thing many times (added the new code within a few seconds) but the addon changes the value to 000000 and crashes (within milliseconds I believe).

The addon resets the otp to 000000 only if the OTP mechanism starts. Please share some debug logs.

Can you guide me to where I can find such?

ahlburg commented 1 month ago

Ok, need to rephrase due too my stupidity.. Its working now, i was actually receiving a code... but on my volvo app user account, not on my volvo dev account. But as you are receiving emails, this would not be applicable to you. i fixed my issue with the solutions provided above. What i did: Started the addon: volvo2mqtt Opened: Settings - Devices & Services - Entities Searched for: OTP Open the entity and provided the newly received code + enter, and close Side remark, first time i did this.. my addon just stopped and i noticed the code changed back to 0. Did the same, but a bit faster. Code remains the same now.. All this is without any restarts.

OK, lucky you ;-) I have done the exact same thing many times (added the new code within a few seconds) but the addon changes the value to 000000 and crashes (within milliseconds I believe).

The addon resets the otp to 000000 only if the OTP mechanism starts. Please share some debug logs.

This is what I get from the addon (not debug log): May 29 13:56:02 volvo2mqtt [106] - INFO: Starting volvo2mqtt version v1.9.2 May 29 13:56:02 volvo2mqtt [106] - DEBUG: MQTT Credentials - Host core-mosquitto Port: 1883 User: addons Pass: juubeo5pithaiCooph0baereeP1zafeuthoopoonuk1iech6Ahphiteequai7uur May 29 13:56:02 volvo2mqtt [106] - INFO: Starting login with OTP Traceback (most recent call last): File "/volvoAAOS2mqtt/main.py", line 15, in authorize() File "/volvoAAOS2mqtt/volvo.py", line 73, in authorize response = send_otp(auth_session, response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/volvoAAOS2mqtt/volvo.py", line 164, in send_otp raise Exception(message["details"][0]["userMessage"]) Exception: This passcode is invalid or has expired. s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

Dielee commented 1 month ago

This is the Volvo API response. Either your OTP is wrong, expired or used somewhere else.

ahlburg commented 1 month ago

This is the Volvo API response. Either your OTP is wrong, expired or used somewhere else.

How do you mean? How shall I be able to input the correct OTP from email that I receive when the addon crashes before I can do that? The addon crashes because OTP is wrong? Catch 22 here. Can you please guide me how to start the addon and have it running for more than 1 second to be able to input the OTP that I receive from Volvo when I (try to) start the addon? Is there any way to "start over" and get rid of the addon and start from scratch? Something is obviously broken here...

ahlburg commented 1 month ago

Can you please explain; should it be possible to change the value of "text.volvo_otp" without the addon running? The addon is not running here. If I post a new value to "volvoAAOS2mqtt/otp_code" with mqtt, is there any way I can see if that works? Is it supposed to change the value of "text.volvo_otp"-entity?

ahlburg commented 1 month ago
  1. Starting the addon to get a new email with the 6-digit code from Volvo.¨
  2. 1 second later copy/pasting that code into a "push" with mqtt as per your instructions. (888212)
  3. starting the addon again after it crashed due to wrong code under step 1.
  4. Looking at the log for the "text.volvo_otp"-entity that correctly shows my 6-digits and the second after changing it to 000000 and crashing the addon once again.

What is wrong here?

Skärmavbild 2024-05-29 kl  16 38 10
Dielee commented 1 month ago

If the otp is isn't valid, the addon restarts and tries again. That's the reason for 000000 after reboot. I don't know why the Volvo API don't want your OTP.

ahlburg commented 1 month ago

Do you know where I can test the "OTP" function? Very little informaion about Volvo and OTP... Any ideas how I can use this addon?

Dielee commented 1 month ago

There is no possibility to "test". OTP is only valid for a few seconds. Have you tried to wait a few seconds before pasting the OTP?

ahlburg commented 1 month ago

I think I have tried everything. What is the order of things here? 1. Start the addon so it calls for a new OTP from Volvo API. 2. Watch the addon crash because it can't find a correct OTP. 3. Open email, paste the received code and push it with mqtt. 4. Start the addon and hope for the best?

ahlburg commented 1 month ago

Do you mean that Volvo has a system that have OTPs that only works for "a few seconds"? Sounds like a very strange policy...