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 <erik@montnemery.com>

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
pull/52630/head
Chris 2021-07-07 01:34:14 -07:00 committed by GitHub
parent c5d806fdbe
commit 45fbc18eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -132,7 +132,6 @@ class MySensorsLight(mysensors.device.MySensorsEntity, LightEntity):
def _turn_on_rgb_and_w(self, hex_template: str, **kwargs: Any) -> None: def _turn_on_rgb_and_w(self, hex_template: str, **kwargs: Any) -> None:
"""Turn on RGB or RGBW child device.""" """Turn on RGB or RGBW child device."""
assert self._hs assert self._hs
assert self._white is not None
rgb = list(color_util.color_hs_to_RGB(*self._hs)) rgb = list(color_util.color_hs_to_RGB(*self._hs))
white = self._white white = self._white
hex_color = self._values.get(self.value_type) 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 hex_template == "%02x%02x%02x%02x":
if new_white is not None: if new_white is not None:
rgb.append(new_white) rgb.append(new_white)
else: elif white is not None:
rgb.append(white) rgb.append(white)
else:
rgb.append(0)
hex_color = hex_template % tuple(rgb) hex_color = hex_template % tuple(rgb)
if len(rgb) > 3: if len(rgb) > 3:
white = rgb.pop() white = rgb.pop()