Skip to content

Commit

Permalink
Update light state parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 16, 2024
1 parent 6b365df commit c580cb3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions custom_components/yandex_station/light.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from homeassistant.components.light import ColorMode, LightEntity, LightEntityFeature
from homeassistant.util.color import color_temperature_to_hs

from .core.entity import YandexEntity
from .hass import hass_utils
Expand Down Expand Up @@ -69,14 +70,16 @@ def internal_update(self, capabilities: dict, properties: dict):

# check if color exists in update
if "color" in capabilities:
try:
item = capabilities["color"]
value = item.get("value")
if isinstance(value, dict):
self._attr_hs_color = (value["h"], value["s"])
elif isinstance(value, int):
# fix https://github.com/AlexxIT/YandexStation/issues/465
item = capabilities["color"]
self._attr_hs_color = (item["value"]["h"], item["value"]["s"])
self._attr_effect = item["name"]
except:
self._attr_hs_color = color_temperature_to_hs(value)
else:
self._attr_hs_color = None
self._attr_effect = None
self._attr_effect = item["name"]

async def async_turn_on(
self,
Expand Down

0 comments on commit c580cb3

Please sign in to comment.