Fix KNX issue if 0 kelvin is reported by device (#44392)

Co-authored-by: Matthias Alphart <farmio@alphart.net>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
PhiBo 2020-12-22 13:28:37 +01:00 committed by GitHub
parent 67ed730c08
commit ffbef0bcd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,7 +86,8 @@ class KNXLight(KnxEntity, LightEntity):
"""Return the color temperature in mireds."""
if self._device.supports_color_temperature:
kelvin = self._device.current_color_temperature
if kelvin is not None:
# Avoid division by zero if actuator reported 0 Kelvin (e.g., uninitialized DALI-Gateway)
if kelvin is not None and kelvin > 0:
return color_util.color_temperature_kelvin_to_mired(kelvin)
if self._device.supports_tunable_white:
relative_ct = self._device.current_tunable_white