Skip to content

Commit b09548f

Browse files
committed
Update light for Yandex Station 3
1 parent d1eba39 commit b09548f

File tree

1 file changed

+17
-18
lines changed
  • custom_components/yandex_station

1 file changed

+17
-18
lines changed

custom_components/yandex_station/light.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,23 @@ def internal_update(self, capabilities: dict, properties: dict):
8989
else None
9090
)
9191

92-
# check if color exists in update
93-
if color := capabilities.get("color"):
92+
if animation := capabilities.get("color_animation"):
93+
animation_type = animation["current_animation_type"]
94+
if animation_type == "color":
95+
color = animation["animations"]["color"]
96+
state = color["internal_state"]
97+
if state["instance"] == "hsv":
98+
value = state["value"]
99+
self._attr_hs_color = (value["h"], value["s"])
100+
self._attr_color_mode = ColorMode.HS
101+
elif animation_type == "scene":
102+
scene = animation["animations"]["scene"]
103+
id = scene["variant"]
104+
self._attr_effect = next(
105+
i["name"] for i in self.effects if i["id"] == id
106+
)
107+
108+
elif color := capabilities.get("color"):
94109
value = color.get("value")
95110

96111
if isinstance(value, dict):
@@ -114,22 +129,6 @@ def internal_update(self, capabilities: dict, properties: dict):
114129
else:
115130
self._attr_effect = None
116131

117-
elif animation := capabilities.get("color_animation"):
118-
animation_type = animation["current_animation_type"]
119-
if animation_type == "color":
120-
color = animation["animations"]["color"]
121-
state = color["internal_state"]
122-
if state["instance"] == "hsv":
123-
value = state["value"]
124-
self._attr_hs_color = (value["h"], value["s"])
125-
self._attr_color_mode = ColorMode.HS
126-
elif animation_type == "scene":
127-
scene = animation["animations"]["scene"]
128-
id = scene["variant"]
129-
self._attr_effect = next(
130-
i["name"] for i in self.effects if i["id"] == id
131-
)
132-
133132
async def async_turn_on(
134133
self,
135134
brightness: int = None,

0 commit comments

Comments
 (0)