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
72.63k stars 30.4k forks source link

Roborock Integration: Task Exception - NoneType Cannot Be Interpreted as an Integer and InvalidStateError #128624

Open cloudbr34k84 opened 18 hours ago

cloudbr34k84 commented 18 hours ago

The problem

I'm encountering multiple issues with the Roborock integration in Home Assistant. The integration throws an error related to a NoneType being interpreted as an integer when updating the entity state. Additionally, there is an InvalidStateError occurring during task execution when resolving a future callback. These errors cause the integration to fail in updating the state and handling task exceptions properly.

What version of Home Assistant Core has the issue?

core-2024.10.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Roborock integration

Link to integration documentation on our website

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

Diagnostics information

This issue appears to be related to task execution failures within the Roborock integration. One issue involves a NoneType being passed to the datetime.time function, causing an exception. Another error is related to an InvalidStateError occurring when trying to resolve a future callback, indicating a potential problem with the internal state management of the integration. config_entry-roborock-01JA3W02KACMA9RJQH5WD69RCE.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

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 170, in native_value
    return self.entity_description.get_value(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roborock/time.py", line 53, in <lambda>
    get_value=lambda cache: datetime.time(
TypeError: 'NoneType' object cannot be interpreted as an integer

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

It appears that the integration fails to handle a scenario where None is returned from a cache or state update, and the future task execution fails due to an invalid state. Addressing both of these issues will help ensure more robust task execution in the Roborock integration.
home-assistant[bot] commented 18 hours ago

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)