home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.07k stars 29.73k forks source link

Lights refresh states while still transitioning #40300

Closed Censored3 closed 1 year ago

Censored3 commented 3 years ago

The problem

When doing a light transition, HA immediately sets the light's state to its supposed destination state. During transition, the light's -current- state gets polled (externally?), causing an intermediate state update. This is especially problematic for automations: turn off a light with transition - HA sets it to 'off' which triggers relevant automations. In reality, the light is still transitioning, and something polls the light's current state, which flows back to HA. HA picks this up as a "light turned on" state change, triggering the relevant automations.

Ie: Set a light scene on "light turn on" and start a timer. On timer finish, turn_off light with transition 10. Light starts to turn off, but triggers the set scene and restarts the timer while turning off - it will loop indefinitely.

I am using Hue bulbs, which I suppose it is related, but not limited to. I suspect this is related to the need of polling the Hue bulbs for their current status, causing a chain of (state) updates that flow through to HA.

I'm seeing this exact same behavior with different integrations: native Hue hub, deconz, as well as ZHA.

The only issue/info I could find regarding this, and I'm pretty sure it's the same underlying problem but described differently: #32894

Environment

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

An idea for an approach could be to introduce a new light state "transitioning", with some internal logic to block external updates (but, still allow internal updates) to the light for the duration of the transition, and refresh state after transition is complete? I guess that would also fix the other mentioned issue #32894, as well as be used in automations. Suppose this could come in handy for other light integrations (that properly handle the transition) as well.

TheJulianJES commented 3 years ago

Can reproduce this with the newer ZHA hue bulbs and some OSRAM lights. The behavior is not present on the older ZLL Philips hue bulbs. (Using the ZHA integration in Home Assistant)

probot-home-assistant[bot] commented 3 years ago

light documentation light source (message by IssueLinks)

TheJulianJES commented 3 years ago

Video of how it looks using a Hue ZHA bulb (with attribute reports): https://streamable.com/ks1vav (5th gen E27 bulbs (LCA001) with (latest) 1.65.9_hB3217DF4 firmware. These sends attribute reports. (260 ZHA profile) When HASS restarts, it doesn't update the color in the UI (defaults to the "yellow") (even when polling can be seen in the debug logs, the color doesn't update). It also doesn't update when changing it via the bluetooth Hue app - the brightness however, even updates in the 0.1s transition time of ZHA in Hass. This produces the "laggy looking" brightness slider in the video above.

The 3rd gen E27 (example here is a E14 LCT012, but it's the same for all Hue ZLL lights) with the latest firmware of 1.50.2_r30933 and the 49246 ZLL profile don't send these attribute reports (doesn't change color nor brightness - only changes brightness when polling, I guess). These bulbs don't show the issue.

(The related bug (not displaying the color of the attribute reports) might be kind of mentioned here: https://github.com/home-assistant/core/issues/38202#issuecomment-665377179)

Censored3 commented 3 years ago

Just want to add and clarify that my issue is with bulbs that I think are previous gen (like LTW013, LWB010, LCT015, LTC001). I only sometimes see these "laggy" transitions, it seems to me more like there is some kind of (external?) polling that is then updating HA while it's still carrying out another action, or HA polling the respective integration?

It could be related, but I'm not sure it is. Solution could be the same, anyway.

DiederikvandenB commented 3 years ago

I am experiencing the same issue as @Censored3.

New Hue bulb (LWA001) works fine, but my LCT015 and LCT012 bulbs have state issues. I cannot toggle the lights on or off, yet I can through the Phoscon web app.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

TheJulianJES commented 3 years ago

This is still present in 2021.1.5.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

TheJulianJES commented 3 years ago

Still present in 2021.4.6. Should mostly be fixed by https://github.com/home-assistant/core/pull/48777 (Perhaps a check should also be added to ignore a poll if it happens while transitioning? (currently only attribute reports are ignored)

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

TheJulianJES commented 3 years ago

Still present in 2021.8.0 (betas).

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

TheJulianJES commented 2 years ago

Still present in 2021.10.5.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

TheJulianJES commented 2 years ago

Still present in 2021.12.10 and likely also in 2022.02.0

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.