From 10e796e9d5916ce214d23e6aeaf5d757638b07b1 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Wed, 21 Dec 2022 23:28:41 +0100 Subject: [PATCH] Fix issues with Color temperature conversions in Hue (#83982) --- homeassistant/components/hue/v2/light.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/hue/v2/light.py b/homeassistant/components/hue/v2/light.py index 0f7cc6cdbab..b925177f26b 100644 --- a/homeassistant/components/hue/v2/light.py +++ b/homeassistant/components/hue/v2/light.py @@ -35,6 +35,9 @@ from .helpers import ( ) EFFECT_NONE = "None" +FALLBACK_MIN_MIREDS = 153 # 6500 K +FALLBACK_MAX_MIREDS = 500 # 2000 K +FALLBACK_MIREDS = 173 # halfway async def async_setup_entry( @@ -141,21 +144,24 @@ class HueLight(HueBaseEntity, LightEntity): """Return the color temperature.""" if color_temp := self.resource.color_temperature: return color_temp.mirek - return 0 + # return a fallback value to prevent issues with mired->kelvin conversions + return FALLBACK_MIREDS @property def min_mireds(self) -> int: """Return the coldest color_temp that this light supports.""" if color_temp := self.resource.color_temperature: return color_temp.mirek_schema.mirek_minimum - return 0 + # return a fallback value to prevent issues with mired->kelvin conversions + return FALLBACK_MIN_MIREDS @property def max_mireds(self) -> int: """Return the warmest color_temp that this light supports.""" if color_temp := self.resource.color_temperature: return color_temp.mirek_schema.mirek_maximum - return 0 + # return a fallback value to prevent issues with mired->kelvin conversions + return FALLBACK_MAX_MIREDS @property def supported_color_modes(self) -> set | None: