Skip to content

Commit a5d7467

Browse files
committed
Fix Yandex matter strip
1 parent 5cfb2ba commit a5d7467

File tree

2 files changed

+276
-1
lines changed

2 files changed

+276
-1
lines changed

custom_components/yandex_station/light.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ def internal_update(self, capabilities: dict, properties: dict):
8686
self._attr_hs_color = color_temperature_to_hs(value)
8787
else:
8888
self._attr_hs_color = None
89-
self._attr_effect = item["name"]
89+
self._attr_effect = (
90+
item["name"]
91+
if "name" in item
92+
else next(i["name"] for i in self.effects if i["id"] == item["id"])
93+
)
9094

9195
async def async_turn_on(
9296
self,

tests/test_light.py

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,274 @@ def test_issue711():
605605
"supported_color_modes": [ColorMode.ONOFF],
606606
"supported_features": 0,
607607
}
608+
609+
610+
def test_strip():
611+
device = {
612+
"id": "xxx",
613+
"external_id": "iot_matter_XXXXXXXXXXXX_1",
614+
"name": "Лента",
615+
"type": "devices.types.light.strip",
616+
"icon_url": "https://avatars.mds.yandex.net/get-iot/icons-devices-devices.types.light.strip.svg/orig",
617+
"capabilities": [
618+
{
619+
"reportable": true,
620+
"retrievable": true,
621+
"type": "devices.capabilities.on_off",
622+
"state": {"instance": "on", "value": true},
623+
"parameters": {"split": false},
624+
"can_be_deferred": true,
625+
},
626+
{
627+
"reportable": true,
628+
"retrievable": true,
629+
"type": "devices.capabilities.color_setting",
630+
"state": {
631+
"instance": "scene",
632+
"value": {"id": "romance", "steps": null},
633+
},
634+
"parameters": {
635+
"instance": "color",
636+
"name": "цвет",
637+
"palette": [
638+
{
639+
"id": "soft_white",
640+
"name": "Мягкий белый",
641+
"type": "white",
642+
"value": {"h": 32, "s": 67, "v": 100},
643+
},
644+
{
645+
"id": "warm_white",
646+
"name": "Теплый белый",
647+
"type": "white",
648+
"value": {"h": 33, "s": 49, "v": 100},
649+
},
650+
{
651+
"id": "white",
652+
"name": "Белый",
653+
"type": "white",
654+
"value": {"h": 33, "s": 28, "v": 100},
655+
},
656+
{
657+
"id": "daylight",
658+
"name": "Дневной белый",
659+
"type": "white",
660+
"value": {"h": 36, "s": 35, "v": 97},
661+
},
662+
{
663+
"id": "cold_white",
664+
"name": "Холодный белый",
665+
"type": "white",
666+
"value": {"h": 222, "s": 4, "v": 98},
667+
},
668+
{
669+
"id": "red",
670+
"name": "Красный",
671+
"type": "multicolor",
672+
"value": {"h": 0, "s": 65, "v": 100},
673+
},
674+
{
675+
"id": "coral",
676+
"name": "Коралловый",
677+
"type": "multicolor",
678+
"value": {"h": 8, "s": 55, "v": 98},
679+
},
680+
{
681+
"id": "orange",
682+
"name": "Оранжевый",
683+
"type": "multicolor",
684+
"value": {"h": 25, "s": 70, "v": 100},
685+
},
686+
{
687+
"id": "yellow",
688+
"name": "Желтый",
689+
"type": "multicolor",
690+
"value": {"h": 40, "s": 70, "v": 100},
691+
},
692+
{
693+
"id": "lime",
694+
"name": "Салатовый",
695+
"type": "multicolor",
696+
"value": {"h": 73, "s": 96, "v": 100},
697+
},
698+
{
699+
"id": "green",
700+
"name": "Зеленый",
701+
"type": "multicolor",
702+
"value": {"h": 120, "s": 55, "v": 90},
703+
},
704+
{
705+
"id": "emerald",
706+
"name": "Изумрудный",
707+
"type": "multicolor",
708+
"value": {"h": 160, "s": 80, "v": 90},
709+
},
710+
{
711+
"id": "turquoise",
712+
"name": "Бирюзовый",
713+
"type": "multicolor",
714+
"value": {"h": 180, "s": 80, "v": 90},
715+
},
716+
{
717+
"id": "cyan",
718+
"name": "Голубой",
719+
"type": "multicolor",
720+
"value": {"h": 190, "s": 60, "v": 100},
721+
},
722+
{
723+
"id": "blue",
724+
"name": "Синий",
725+
"type": "multicolor",
726+
"value": {"h": 225, "s": 55, "v": 90},
727+
},
728+
{
729+
"id": "moonlight",
730+
"name": "Лунный",
731+
"type": "multicolor",
732+
"value": {"h": 231, "s": 10, "v": 100},
733+
},
734+
{
735+
"id": "lavender",
736+
"name": "Сиреневый",
737+
"type": "multicolor",
738+
"value": {"h": 255, "s": 55, "v": 90},
739+
},
740+
{
741+
"id": "violet",
742+
"name": "Фиолетовый",
743+
"type": "multicolor",
744+
"value": {"h": 270, "s": 55, "v": 90},
745+
},
746+
{
747+
"id": "purple",
748+
"name": "Пурпурный",
749+
"type": "multicolor",
750+
"value": {"h": 300, "s": 70, "v": 90},
751+
},
752+
{
753+
"id": "orchid",
754+
"name": "Розовый",
755+
"type": "multicolor",
756+
"value": {"h": 305, "s": 50, "v": 90},
757+
},
758+
{
759+
"id": "raspberry",
760+
"name": "Малиновый",
761+
"type": "multicolor",
762+
"value": {"h": 345, "s": 70, "v": 90},
763+
},
764+
{
765+
"id": "mauve",
766+
"name": "Лиловый",
767+
"type": "multicolor",
768+
"value": {"h": 340, "s": 45, "v": 90},
769+
},
770+
],
771+
"custom_palette": null,
772+
"scenes": [
773+
{"id": "sunrise", "name": "Рассвет"},
774+
{"id": "sunset", "name": "Закат"},
775+
{"id": "circadian", "name": "Циркадный"},
776+
{"id": "party", "name": "Вечеринка"},
777+
{"id": "gaming", "name": "Игра"},
778+
{"id": "night", "name": "Вечерний"},
779+
{"id": "romance", "name": "Романтика"},
780+
{"id": "candle", "name": "Свеча"},
781+
{"id": "northern", "name": "Северное сияние"},
782+
{"id": "reading", "name": "Чтение"},
783+
],
784+
"custom_scenes": null,
785+
"custom_scenes_available": true,
786+
"color_model": "hsv",
787+
"temperature_k": {"min": 2700, "max": 6500},
788+
},
789+
},
790+
{
791+
"reportable": true,
792+
"retrievable": true,
793+
"type": "devices.capabilities.range",
794+
"state": {"instance": "brightness", "value": 99},
795+
"parameters": {
796+
"instance": "brightness",
797+
"name": "яркость",
798+
"unit": "unit.percent",
799+
"random_access": true,
800+
"looped": false,
801+
"range": {"min": 1, "max": 100, "precision": 1},
802+
},
803+
},
804+
],
805+
"properties": [],
806+
"item_type": "device",
807+
"skill_id": "YANDEX_IO",
808+
"room_name": "Лоджия",
809+
"status_info": {
810+
"status": "online",
811+
"updated": 1765305703.998412,
812+
"changed": 1764860708.344743,
813+
},
814+
"state": "online",
815+
"render_info": {"icon": {"id": "yandex.light.unicorn", "color": "white"}},
816+
"created": "2025-10-13T14:20:54Z",
817+
"parameters": {
818+
"device_info": {
819+
"manufacturer": "Yandex",
820+
"model": "YNDX-00544",
821+
"hw_version": "0",
822+
"sw_version": "20",
823+
"setup_code": "XXX",
824+
"serial_number": "XXX",
825+
"vendor_id": 5130,
826+
"product_id": 544,
827+
},
828+
"ota_update": {"status": "success", "progress": 100, "version": 0},
829+
},
830+
}
831+
832+
state = update_ha_state(YandexLight, device)
833+
assert state.state == "on"
834+
assert state.attributes == {
835+
"brightness": 252,
836+
"color_mode": ColorMode.HS,
837+
"effect": "Романтика",
838+
"effect_list": [
839+
"Мягкий белый",
840+
"Теплый белый",
841+
"Белый",
842+
"Дневной белый",
843+
"Холодный белый",
844+
"Красный",
845+
"Коралловый",
846+
"Оранжевый",
847+
"Желтый",
848+
"Салатовый",
849+
"Зеленый",
850+
"Изумрудный",
851+
"Бирюзовый",
852+
"Голубой",
853+
"Синий",
854+
"Лунный",
855+
"Сиреневый",
856+
"Фиолетовый",
857+
"Пурпурный",
858+
"Розовый",
859+
"Малиновый",
860+
"Лиловый",
861+
"Рассвет",
862+
"Закат",
863+
"Циркадный",
864+
"Вечеринка",
865+
"Игра",
866+
"Вечерний",
867+
"Романтика",
868+
"Свеча",
869+
"Северное сияние",
870+
"Чтение",
871+
],
872+
"friendly_name": "Лента",
873+
"hs_color": None,
874+
"rgb_color": None,
875+
"supported_color_modes": [ColorMode.HS],
876+
"supported_features": LightEntityFeature.EFFECT,
877+
"xy_color": None,
878+
}

0 commit comments

Comments
 (0)