Skip to content

Commit

Permalink
Merge pull request #1204 from JonathanKang/light-effect-list
Browse files Browse the repository at this point in the history
Add support for light effect and effect_list
  • Loading branch information
AlexxIT authored Nov 6, 2023
2 parents 9f29521 + 5fcc6e8 commit f625291
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/xiaomi_gateway3/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __init__(self, gateway: "XGateway", device: XDevice, conv: Converter):
elif hasattr(conv, "mink") and hasattr(conv, "maxk"):
self._attr_min_mireds = int(1000000 / conv.maxk)
self._attr_max_mireds = int(1000000 / conv.mink)
elif conv.attr == ATTR_EFFECT:
self._attr_supported_features |= LightEntityFeature.EFFECT
self._attr_effect_list = list(conv.map.values())

@callback
def async_set_state(self, data: dict):
Expand All @@ -58,12 +61,15 @@ def async_set_state(self, data: dict):
self._attr_brightness = data[ATTR_BRIGHTNESS]
if ATTR_COLOR_TEMP in data:
self._attr_color_temp = data[ATTR_COLOR_TEMP]
if ATTR_EFFECT in data:
self._attr_effect = data[ATTR_EFFECT]

@callback
def async_restore_last_state(self, state: str, attrs: dict):
self._attr_is_on = state == STATE_ON
self._attr_brightness = attrs.get(ATTR_BRIGHTNESS)
self._attr_color_temp = attrs.get(ATTR_COLOR_TEMP)
self._attr_effect = attrs.get(ATTR_EFFECT)

async def async_update(self):
await self.device_read(self.subscribed_attrs)
Expand Down

0 comments on commit f625291

Please sign in to comment.