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.67k stars 30.42k forks source link

Divide by zero exception in color transform #83923

Closed erkr closed 1 year ago

erkr commented 1 year ago

The problem

I noticed a divide by zero exception thrown by a HUE Integration event handler. It just happened while navigation in the front end (no control of lights). Not seen before. But there was not much flight time with core versions 2022.12.1 and 2022.12.3

What version of Home Assistant Core has the issue?

Core-2022.12.4

What was the last working version of Home Assistant Core?

Core-2022.11.*

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Philips HUE

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant
Source: util/color.py:623 
First occurred: 12:31:03 (1 occurrences) 
Last logged: 12:31:03

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohue/v2/controllers/base.py", line 253, in _handle_event
    callback(evt_type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/entity.py", line 153, in _handle_event
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 579, in _async_write_ha_state
    attr = self.capability_attributes
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 915, in capability_attributes
    data[ATTR_MAX_COLOR_TEMP_KELVIN] = self.max_color_temp_kelvin
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 893, 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 623, in color_temperature_mired_to_kelvin
    return math.floor(1000000 / mired_temperature)
ZeroDivisionError: division by zero

Additional information

No response

home-assistant[bot] commented 1 year 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` Change the title of 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.

(message by CodeOwnersMention)


hue documentation hue source (message by IssueLinks)

marcelveldt commented 1 year ago

This may be an incidental fluke where the color temperature was reported as 0 by the light. For example during a firmware update or a 3rd party Hue light not compliant to specs. Please keep an eye on it of the error returns or was just a one time thing. We do not have control over the data integrity. If Hue reports a value of 0 for the color temperature (which does not exist), than this error will popup. If this is something happening more often we can place a workaround for it in our code.

Beer17HWAM commented 1 year ago

See https://github.com/home-assistant/core/issues/83969 I have it after the Hue Bridge update 1.55.195082050.

Beer17HWAM commented 1 year ago

@erkr Do you also have NON-Philips bulbs? See https://github.com/home-assistant/core/issues/83969

erkr commented 1 year ago

@marcelveldt 👍 @Beer17HWAM yes I have many non Phipps devices, including some colour led strips