Skip to content

Fix light with active scene (#814), Station 3 backlight scenes and colors via color_animation - #816

Merged
AlexxIT merged 3 commits into
AlexxIT:masterfrom
xom4ek:station3-backlight
Sep 30, 2026
Merged

AlexxIT merged 3 commits into
AlexxIT:masterfrom
xom4ek:station3-backlight

Conversation

@xom4ek

@xom4ek xom4ek commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Что не так

  1. Свет с активной сценой не создаётся на свежих HA (Color lights from УДЯ fail with "does not report a color mode" when the current color state is a scene (v3.22.0, HA 2026.9.1) #814, продолжение При попытке включить Эмбилампу выходит ошибка. #759 и Fix light color mode on HA 2026.6+ (#759) #812). После 50ef6c1 internal_init заканчивается на self._attr_color_mode = None, а internal_update выставляет режим только для HSV-словаря или целого числа температуры. Если у лампы сейчас активна сцена (color_setting со state.instance = scene и значением {"id", "name"}), режим так и остаётся None, и HA отвечает:
homeassistant.exceptions.HomeAssistantError: light.xxx (<class 'custom_components.yandex_station.light.YandexLight'>) does not report a color mode

По той же причине не создаётся подсветка Яндекс Станции 3 (devices.types.smart_speaker.yandex.station.orion): её состояние приходит через capability color_animation (сцена или цвет), а не через значение color.

  1. Сцены и цвета подсветки Станции 3 через color_setting не работают. light.turn_on с effect шлёт {"type": "devices.capabilities.color_setting", "state": {"instance": "scene", "value": "candle"}}, Quasar отвечает:
{"status": "error", "code": "INTERNAL_ERROR", "message": "Случилось что-то непонятное. Подождите немного и попробуйте ещё раз."}

Приложение и веб (yandex.ru/iot) ставят сцены и цвета через devices.capabilities.color_animation. Запросы из вкладки Network:

{"actions":[{"type":"devices.capabilities.color_animation","state":{"instance":"color_animation","value":{"current_animation_type":"scene","animations":{"scene":{"variant":"polar_lights","variants":[{"id":"polar_lights","options":[]}]}}}}}]}
{"actions":[{"type":"devices.capabilities.color_animation","state":{"instance":"color_animation","value":{"current_animation_type":"color","animations":{"color":{"variant":"blue"}}}}}]}

variant для цвета совпадает с id из палитры color_setting. У сцены candle в options лежит настройка звука, её нужно брать из текущего состояния устройства.

Что сделано

internal_init ставит явный color_mode из набора поддерживаемых вместо None. Хунк тот же, что в #812, так что если #812 вольётся первым, конфликта не будет. Там же выставляется флаг animation, если у устройства есть capability color_animation.

internal_update для обычных ламп при активной сцене ставит ColorMode.HS (если он поддерживается) и кладёт имя сцены в effect. Словарь цвета теперь проверяется на ключ "h": раньше сцена {"id", "name"} роняла KeyError, и internal_update не доходил до конца. Для color_animation: сцена даёт effect и HS, цвет даёт hs_color и effect по variant, температура даёт color_temp_kelvin. Варианты сцен вместе с их options запоминаются. У динамических сцен (sunset, sunrise, circadian) в состоянии приходит "variants": null, и в списке вариантов их нет, поэтому разбор терпит null, а при включении такой сцены отправляется вариант без опций.

async_turn_on у устройств с color_animation отправляет сцену и цвет палитры через color_animation с тем же payload, что у приложения. Если подсветка выключена, в тот же запрос добавляется backlight: true, иначе сцена ставится, а подсветка остаётся выключенной. Остальные устройства работают как раньше, через color и scene.

В IOT_TYPES добавлен color_animation.

Тесты: test_issue814 (лампа в сцене), test_station3_backlight (состояние), test_station3_actions (payload для turn_on и turn_off). test_strip падал на master уже после 50ef6c1 (color_mode = None), теперь он ждёт HS при активной сцене.

Проверка

Станция 3, HA 2026.8.1, v3.22.0 с этим патчем. Сущность создаётся. light.turn_on с любой сценой из effect_list («Свеча», «Северное Сияние», «Лава лампа», «Ночь») и с цветом палитры («Синий») переключает станцию, состояние подтягивается сразу. Выключенная подсветка включается сразу со сценой. hs_color и color_temp_kelvin через color/apply работают как раньше, turn_off дёргает toggle backlight. Устройства без color_animation не затронуты, тесты light проходят.

@saidibragimov90

Copy link
Copy Markdown
Contributor

Reporter of #814 here. The diagnosis matches what I traced independently before finding this PR: 50ef6c10 (#759) replaced modes or {self._attr_color_mode} with a hard self._attr_color_mode = None, and internal_update assigns a mode only when the colour value is a dict (→ HS) or an int (→ COLOR_TEMP). With a scene active neither branch runs — the else branch clears hs_color / color_temp_kelvin and leaves the mode untouched — so color_mode stays None for as long as the scene is set.

One detail that supports going by the shape of the value rather than by the instance: extract_state() in core/entity.py keeps only state["value"] and drops state["instance"], so internal_update never learns that the state was a scene in the first place.

To be clear, I have not run this branch — this is not a test report, only confirmation that the analysis lines up with the setup in #814 (devices.types.light.torchere and devices.types.light.lamp, HA 2026.9.1 / v3.22.0).

I closed my own #817 as a duplicate of this one.

@AlexxIT
AlexxIT merged commit 7d7719b into AlexxIT:master Sep 30, 2026
AlexxIT added a commit that referenced this pull request Sep 30, 2026
@AlexxIT

AlexxIT commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Спасибо. Немного поправил логику, надеюсь ничего не сломал, делал вслепую.

@AlexxIT AlexxIT added this to the master milestone Sep 30, 2026
@saidibragimov90

Copy link
Copy Markdown
Contributor

Спасибо за мёрдж и доработку логики!

@AlexxIT

AlexxIT commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants