From 45fbc18eb02ae3c444d1412945a3d734289b390a Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 7 Jul 2021 01:34:14 -0700 Subject: [PATCH] Fix mysensors rgb light (#52604) * remove assert self._white as not all RGB will have a white channel * suggested change * Update homeassistant/components/mysensors/light.py Co-authored-by: Erik Montnemery Co-authored-by: Franck Nijhof Co-authored-by: Erik Montnemery --- homeassistant/components/mysensors/light.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/mysensors/light.py b/homeassistant/components/mysensors/light.py index 81089f052b6..b08d94cebb0 100644 --- a/homeassistant/components/mysensors/light.py +++ b/homeassistant/components/mysensors/light.py @@ -132,7 +132,6 @@ class MySensorsLight(mysensors.device.MySensorsEntity, LightEntity): def _turn_on_rgb_and_w(self, hex_template: str, **kwargs: Any) -> None: """Turn on RGB or RGBW child device.""" assert self._hs - assert self._white is not None rgb = list(color_util.color_hs_to_RGB(*self._hs)) white = self._white hex_color = self._values.get(self.value_type) @@ -151,8 +150,10 @@ class MySensorsLight(mysensors.device.MySensorsEntity, LightEntity): if hex_template == "%02x%02x%02x%02x": if new_white is not None: rgb.append(new_white) - else: + elif white is not None: rgb.append(white) + else: + rgb.append(0) hex_color = hex_template % tuple(rgb) if len(rgb) > 3: white = rgb.pop()