home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.39k stars 30.65k forks source link

Roborock - Unable to set up integration - 'code': 'auth.err', 'msg': 'auth.err.invalid.token', 'status': 'UNAUTHORIZED' #102487

Closed eclair4151 closed 11 months ago

eclair4151 commented 1 year ago

The problem

I am setting up the robo rock integration for the first time. I have a Q Revo, which is setup in the robo rock app. I go to set up the integration, type in my email, and then type in the one time code I receive. I get a notification on my phone about a new login on my roborock account, but the integration on HA just says 'Failed to setup' with the following error log:

Let me know what else I can provide to help!

Logger: homeassistant.config_entries Source: config_entries.py:399 First occurred: 9:39:37 AM (3 occurrences) Last logged: 9:40:59 AM

Error setting up entry tomerjshemesh@gmail.com for roborock Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 399, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/roborock/init.py", line 32, in async_setup_entry home_data = await api_client.get_home_data(user_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/roborock/api.py", line 708, in get_home_data raise RoborockException(home_response) roborock.exceptions.RoborockException: {'code': 'auth.err', 'msg': 'auth.err.invalid.token', 'status': 'UNAUTHORIZED', 'timestamp': '2023-10-21T18:55:46.087+00:00'}

What version of Home Assistant Core has the issue?

core-2023.10.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Roborock

Link to integration documentation on our website

https://www.home-assistant.io/integrations/roborock/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @humbertogontijo, @lash-l, mind taking a look at this issue as it has been labeled with an integration (roborock) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `roborock` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign roborock` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


roborock documentation roborock source (message by IssueLinks)

BillyFKidney commented 1 year ago

I am experiencing the same issue attempting to setup my Roborock integration.

After entering my verification code into Home Assistant it says the code is invalid. However, I immediately receive a notification in the Roborock app stating my account has been logged into another device: image

Home Assistant 2023.10.5 Supervisor 2023.10.0 Operating System 11.0 Frontend 20231005.0 - latest

Logger: homeassistant.components.roborock.config_flow
Source: components/roborock/config_flow.py:84
Integration: Roborock (documentation, issues)
First occurred: 4:06:40 PM (1 occurrences)
Last logged: 4:06:40 PM

wrong value type for field "rriot" - should be "roborock.containers.RRiot | None" instead of value "{'u': 'VALUE', 's': 'VALUE', 'h': 'VALUE', 'k': 'VALUE', 'r': {'r': 'US', 'a': 'https://api-us.roborock.com', 'm': 'ssl://mqtt-us-2.roborock.com:8883', 'l': 'https://wood-us.roborock.com'}}" of type "dict"
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/roborock/config_flow.py", line 84, in async_step_code
    login_data = await self._client.code_login(code)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/roborock/api.py", line 660, in code_login
    return UserData.from_dict(user_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/roborock/containers.py", line 90, in from_dict
    return from_dict(cls, decamelize_obj(data, ignore_keys), config=Config(cast=[Enum]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dacite/core.py", line 68, in from_dict
    raise WrongTypeError(field_path=field.name, field_type=field.type, value=value)
dacite.exceptions.WrongTypeError: wrong value type for field "rriot" - should be "roborock.containers.RRiot | None" instead of value "{'u': 'VALUE', 's': 'VALUE', 'h': 'VALUE', 'k': 'VALUE', 'r': {'r': 'US', 'a': 'https://api-us.roborock.com', 'm': 'ssl://mqtt-us-2.roborock.com:8883', 'l': 'https://wood-us.roborock.com'}}" of type "dict"
Codibex commented 1 year ago

I have the same issue after setup the integration. Notification in the app that someone logged in but the mentioned error in home assistant.

Update: With the solution found in the issue #101857 it worked for one day. But now I get the same issue AttributeError: 'types.UnionType' object has no attribute 'origin' as mentioned in the other issue.

So, I am not sure if it is the same root cause but the solution from the other issue worked for this issue.

V3lop5 commented 1 year ago

Hi there, I got the same issue.

To ensure no conflict to other integrations (like mentioned in other issues) I set up a new home assistant instance using docker. Still got the error:

Logger: homeassistant.config_entries
Source: config_entries.py:399
First occurred: 18:04:16 (3 occurrences)
Last logged: 18:11:52

Error setting up entry XXXXXXXXX@gmail.com for roborock
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 399, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roborock/__init__.py", line 32, in async_setup_entry
    home_data = await api_client.get_home_data(user_data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/roborock/api.py", line 708, in get_home_data
    raise RoborockException(home_response)
roborock.exceptions.RoborockException: {'code': 'auth.err', 'msg': 'auth.err.invalid.token', 'status': 'UNAUTHORIZED', 'timestamp': '2023-10-29T18:36:46.066+00:00'}

In my case my Raspberry Pi was out of sync with the current local time. (No clue how that happend, but due to time change in Germany the difference was even worse.) To fix the local time I used sudo sntp -s time.google.com inside a bash of my RPi. After that the integration works fine.

I hope this is a permanent fix.

docwisdom commented 1 year ago

Same issue here, however the error I receive when putting in my verification code is "Unknown error". My Qrevo was working great in HA for about a month, I noticed my integration stopped working near the time that I shared my Q Revo with my wife. Not sure if this changes Roborocks authentication somehow.

petuniabowl commented 11 months ago

I had the same issue presentation (running HA as an app in TrueNAS Scale) and eventually figured out that the issue was that my system time was out of sync.

It took me a while to figure that out because:

eclair4151 commented 11 months ago

Yea I think it has something to do with timezone settings. I was running it as a trueNAS Scale app also, but was having all sorts of other issues with some other integrations. Ended up getting a rasp pi with HAOS and now it works perfectly. So for others I would say check your timezone settings. Or bite the bullet and run the OS as its own thing.

docwisdom commented 11 months ago

Not a time issue. Current tz is America/Los Angeles and all logs show correct time to the second. Running HA OS on mini PC.

I was able to successfully reconnect the integration today though. Unsure if it was an HA update or something on Roborocks side.

BillyFKidney commented 11 months ago

Yea I think it has something to do with timezone settings. I was running it as a trueNAS Scale app also, but was having all sorts of other issues with some other integrations. Ended up getting a rasp pi with HAOS and now it works perfectly. So for others I would say check your timezone settings. Or bite the bullet and run the OS as its own thing.

I am running HAOS on an x86 (bare metal) so I doubt it is just a timezone issue.