Skip to content

Commit

Permalink
Fix sets invalid supported color modes #475
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 3, 2024
1 parent d882883 commit dd5f9d2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/yandex_station/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ class YandexLight(LightEntity, YandexEntity):
effects: list

def internal_init(self, capabilities: dict, properties: dict):
self._attr_supported_color_modes = set()
self._attr_color_mode = ColorMode.ONOFF

if item := capabilities.get("brightness"):
self.max_brightness = item["range"]["max"]
self.min_brightness = item["range"]["min"]
self._attr_supported_color_modes.add(ColorMode.BRIGHTNESS)
self._attr_color_mode = ColorMode.BRIGHTNESS

if item := capabilities.get("color"):
self.effects = []

if items := item["palette"]:
self.effects += items
self._attr_supported_color_modes.add(ColorMode.HS)
self._attr_color_mode = ColorMode.HS

if items := item["scenes"]:
self.effects += items
Expand All @@ -53,6 +53,8 @@ def internal_init(self, capabilities: dict, properties: dict):
self._attr_effect_list = [i["name"] for i in self.effects]
self._attr_supported_features = LightEntityFeature.EFFECT

self._attr_supported_color_modes = {self._attr_color_mode}

def internal_update(self, capabilities: dict, properties: dict):
if "on" in capabilities:
self._attr_is_on = capabilities["on"]
Expand Down

0 comments on commit dd5f9d2

Please sign in to comment.