Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roborock Integration: AttributeError due to incorrect handling of cached data #125878

Open
cloudbr34k84 opened this issue Sep 13, 2024 · 2 comments

Comments

@cloudbr34k84
Copy link

cloudbr34k84 commented Sep 13, 2024

The problem

I encountered multiple errors related to the Roborock integration in Home Assistant. The first issue is an InvalidStateError, which seems to occur when handling RoborockFuture callbacks. The second issue is an AttributeError when processing scheduling times from the cache. These errors appear in the logs without any specific user action triggering them.

Steps to reproduce:

  1. Configure the Roborock integration.
  2. Let the integration run.
  3. Observe the log for errors, particularly those related to cached data and time values.

Expected result: The integration should correctly handle the cached data and manage the scheduling time without errors.

Actual result: The integration throws multiple exceptions, including an InvalidStateError when resolving future callbacks and an AttributeError when retrieving start_hour and start_minute from cached data.

What version of Home Assistant Core has the issue?

2024.9.1

What was the last working version of Home Assistant Core?

Unsure

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Roborock

Link to integration documentation on our website

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

Diagnostics information

config_entry-roborock-e232f3c6d63e9616ff73313be86119ba.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant
Source: components/roborock/time.py:53
First occurred: 2:05:39 pm (2 occurrences)
Last logged: 2:06:10 pm

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1047, in _async_update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/time/__init__.py", line 95, in state
    if self.native_value is None:
       ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roborock/time.py", line 169, in native_value
    return self.entity_description.get_value(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roborock/time.py", line 53, in <lambda>
    hour=cache.value.get("start_hour"), minute=cache.value.get("start_minute")
         ^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'get'
Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:147
First occurred: 2:05:20 pm (1 occurrences)
Last logged: 2:05:20 pm

Error doing job: Exception in callback RoborockFuture._resolve(({'enabled': 0, 'end_hour': 8, 'end_minute': 0, 'start_hour': 22, ...}, None)) (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.12/site-packages/roborock/roborock_future.py", line 19, in _resolve
    self.fut.set_result(item)
asyncio.exceptions.InvalidStateError: invalid state

Additional information

No response

@home-assistant
Copy link

Hey there @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.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


roborock documentation
roborock source
(message by IssueLinks)

@allenporter
Copy link
Contributor

The invalid state error is tracked in #119733 and humbertogontijo/python-roborock#222 -- we can keep this about the attribute error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants