From 2c181181e15a4a45168d4e185f1309f63043a867 Mon Sep 17 00:00:00 2001 From: Oxan van Leeuwen Date: Sat, 14 Aug 2021 08:27:47 +0200 Subject: [PATCH] Clamp color temperature to supported range in ESPHome light (#54595) ESPHome devices initially report a color temperature of 0 or 1 until it has been changed by the user. This broke the conversion from RGBWW to an RGB color. Fixes #54293. --- homeassistant/components/esphome/light.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/esphome/light.py b/homeassistant/components/esphome/light.py index b89a75ab76a..aeecc22d9f1 100644 --- a/homeassistant/components/esphome/light.py +++ b/homeassistant/components/esphome/light.py @@ -230,7 +230,7 @@ class EsphomeLight(EsphomeEntity[LightInfo, LightState], LightEntity): # Try to reverse white + color temp to cwww min_ct = self._static_info.min_mireds max_ct = self._static_info.max_mireds - color_temp = self._state.color_temperature + color_temp = min(max(self._state.color_temperature, min_ct), max_ct) white = self._state.white ww_frac = (color_temp - min_ct) / (max_ct - min_ct)