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
74.13k stars 31.12k forks source link

HUE ZeroDivisionError #116258

Open erkr opened 7 months ago

erkr commented 7 months ago

The problem

Since my update to core 2024.4.4 I see division by zero errors. My HUE setup has not changed over the last months.

What version of Home Assistant Core has the issue?

Core-2024.4.4

What was the last working version of Home Assistant Core?

Core-2024.4.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Hue

Link to integration documentation on our website

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

Diagnostics information

According my logbook, errors started after an innr PL 110 led was switched on: image

That is a dimmable light only. No colors, no color temperature. Properties of this light in dev tools:

supported_color_modes:
  - brightness
color_mode: null
brightness: null
mode: normal
dynamics: none
friendly_name: Aanrecht
supported_features: 40

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant
Source: util/color.py:633
First occurred: 12:46:33 (131 occurrences)
Last logged: 19:19:18

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohue/v2/controllers/base.py", line 247, in _handle_event
    callback(evt_type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/entity.py", line 138, in _handle_event
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1051, in __async_calculate_state
    capability_attr = self.capability_attributes
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1027, in capability_attributes
    max_color_temp_kelvin = self.max_color_temp_kelvin
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 1005, in max_color_temp_kelvin
    return color_util.color_temperature_mired_to_kelvin(self.min_mireds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/color.py", line 633, in color_temperature_mired_to_kelvin
    return math.floor(1000000 / mired_temperature)
                      ~~~~~~~~^~~~~~~~~~~~~~~~~~~
ZeroDivisionError: division by zero

Additional information

The light was unresponsive for new commands. The electronics got into some error state. After power cycling the light, these where the properties, with a responsive light:

supported_color_modes:
  - brightness
color_mode: brightness
brightness: 255
mode: normal
dynamics: none
friendly_name: Aanrecht
supported_features: 40
home-assistant[bot] commented 7 months ago

Hey there @balloob, @marcelveldt, mind taking a look at this issue as it has been labeled with an integration (hue) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `hue` 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 hue` 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)


hue documentation hue source (message by IssueLinks)

erkr commented 6 months ago

The event was a one-off. Didn't happen again. But guarding the code,at the spot where the exceptions came from, against divisions by zero is always a good idea

erkr commented 4 months ago

Update: this happens only intermittently (after several weeks). Once it happens, the HUE integration is in some kind of errornous state and spams the log with these errors, till I reload the integration

issue-triage-workflows[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

erkr commented 1 month ago

Still the case