Skip to content

Commit

Permalink
Fix light state for some mesh bulbs #1335
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 1, 2024
1 parent b99b74e commit eaf49eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/xiaomi_gateway3/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ def on_init(self):
self._attr_supported_color_modes = modes if modes else {self._attr_color_mode}

def set_state(self, data: dict):
if self.attr in data:
self._attr_is_on = bool(data[self.attr])
# we turn_on light on any brightness or color_temp data without light state
# fix https://github.com/AlexxIT/XiaomiGateway3/issues/1335
if ATTR_BRIGHTNESS in data:
self._attr_brightness = data[ATTR_BRIGHTNESS]
data.setdefault(self.attr, True)
if ATTR_COLOR_TEMP in data:
self._attr_color_temp = data[ATTR_COLOR_TEMP]
self._attr_color_mode = ColorMode.COLOR_TEMP
data.setdefault(self.attr, True)
if self.attr in data:
self._attr_is_on = bool(data[self.attr])
if ATTR_HS_COLOR in data:
self._attr_hs_color = data[ATTR_HS_COLOR]
self._attr_color_mode = ColorMode.HS
Expand Down

0 comments on commit eaf49eb

Please sign in to comment.