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.14k stars 29.81k forks source link

Philips Hue lights states still not correctly updating on 2021.12.3 #62252

Closed nagubal closed 2 years ago

nagubal commented 2 years ago

The problem

I am still having incorrect Hue light states after updating to 2021.12.3 last night.

I added the a sample of the error found in the logs. It happened 24 times since updating 12 hours ago. Kind regards.

What version of Home Assistant Core has the issue?

core-2021.12.3

What was the last working version of Home Assistant Core?

core-2021.11

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Philips Hue

Link to integration documentation on our website

https://www.home-assistant.io/integrations/hue

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2021-12-18 10:14:27 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
callback(type, cur_item)
File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'

Additional information

My Hue bridge is in a separate VLAN.

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

hue documentation hue source (message by IssueLinks)

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

Hey there @balloob, @marcelveldt, mind taking a look at this issue as it has been labeled with an integration (hue) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

marcelveldt commented 2 years ago

Thanks for your report, still some leftover issue in there as it appears. Seems this is the connection guard which kicks in after 2 hours of not receiving any state from the bridge. Due to to the single way nature of the eventstream we have no way to detect if the connection failed on us so there's a check in there that if there was no event within 2 hours we assume the connection is dead and restart it.

I'll see if I can make it more robust and fix the error you see when it's reloading.

marcelveldt commented 2 years ago

For now, a dirty workaround would be to simply turn on/off some light or something every hour to trigger an update from the bridge.

tristanXme commented 2 years ago

I've got some lamps on the ceiling, that can be controlled by the hue bridge and by the "normal" switch, which fully switches them off. When they are totaly "cut" from power, home assistant still thinks it can turn it on and the state changes to "on" until i switch it off in home assistant again -> But the lamp is the whole time not reachable, as its whithout power.

State in the Hue App is always correct....

marcelveldt commented 2 years ago

@tristanXme that's a different issue than mentioned here. This may happen with non-Philips brand dimmers that don't report their state correctly. We're currently investigating how to handle this in a universal way, for now we bypas sthe availability check for 3rd party bulbs completely as it is very unreliable. What brand are they ?

tristanXme commented 2 years ago

@marcelveldt I use some philips hue bulps / lamps which are always only switched by app, so they always have power.

The ones that are also powered off "hard" by a regular switch are ikea lamps like this one: https://www.ikea.com/de/de/p/floalt-led-lichtpaneel-dimmbar-weissspektrum-40436316/

and two ikea tradfri bulbs in a "regular" ceiling lamp.

Before upgrading to 2021.12.X (dont know on which (sub-)version it stopped working) everything was fine.

ballakers commented 2 years ago

I've got some lamps on the ceiling, that can be controlled by the hue bridge and by the "normal" switch, which fully switches them off. When they are totaly "cut" from power, home assistant still thinks it can turn it on and the state changes to "on" until i switch it off in home assistant again -> But the lamp is the whole time not reachable, as its whithout power.

State in the Hue App is always correct....

as said a different issue but just remove your switches anyways to alleviate that hassle

ballakers commented 2 years ago

The UI is noticeable slower reporting the hue states also (although I am no longer having state issues aside from minor delay). Example switch on or off entire area - Tuya local, ZHA and Caseta all instantly change state in the UI while the hue stuff is a half a second or more behind.

tristanXme commented 2 years ago

U are a funny guy. Next time u suggest to remove home Assistant to avoid bugs?

ballakers commented 2 years ago

U are a funny guy. Next time u suggest to remove home Assistant to avoid bugs?

Only speaking from my own experience, wasn't trying to be funny at all. I have pico remotes, various ZHA buttons etc or those Lutron aurora dimmers to control all the HA stuff. Pretty simple - twist your wires together to make your breaker the only switch and then put a nice looking pico remote or something in place of the old switch. Or much easier on a single gang to throw your hue dimmer or the like overtop of the removed switch. May help the wife acceptance factor too - after all a smart bulb without power is dumber than a regular bulb. Anywho this isn't the place for this discussion, apologies to the mods in advance lol Lastly I could not fathom removing HA from my life.

marcelveldt commented 2 years ago

The UI is noticeable slower reporting the hue states also (although I am no longer having state issues aside from minor delay). Example switch on or off entire area - Tuya local, ZHA and Caseta all instantly change state in the UI while the hue stuff is a half a second or more behind.

There shouldn't be any delays. Could be an indication that your bridge can't cope up. State changes should happen within milliseconds. and are actively pushed by the bridge to HA. Maybe look at your logs if you see any errors or if you have any other software talking to the bridge directly, like Node Red.

AlexanderNaehring commented 2 years ago

I actually have the issue that only some lights persist being reported in the wrong state. E.g. All lights are off, I switch the room on (or use a hue scene), all physical lights turn on as expected. All lights are reported as "on" in home assistant, but some switch back to being reported as "off" 2-3 seconds later. Hue app shows the correct states. Could this be the same issue as discussed here or something else? Im using home assistant OS, latest stable version.

/edit: it seems I imagined that the error persistent after updating to 12.3. At least today I did not experience this behavior. It seems the error I describe was really only in 12.2. Sorry for the confusion. However it at least seems to react slower compared to e.g. core 2021.11.x... Will investigate more.

ballakers commented 2 years ago

The UI is noticeable slower reporting the hue states also (although I am no longer having state issues aside from minor delay). Example switch on or off entire area - Tuya local, ZHA and Caseta all instantly change state in the UI while the hue stuff is a half a second or more behind.

There shouldn't be any delays. Could be an indication that your bridge can't cope up. State changes should happen within milliseconds. and are actively pushed by the bridge to HA. Maybe look at your logs if you see any errors or if you have any other software talking to the bridge directly, like Node Red.

Probably a non-issue (although it was very minor felt like I should raise the issue since I know the HA community likes to pay attention to every detail), nothing else talking to the bridge. I think it is actually they don't report off until fully dimmed down - the lights do starting dimming down to turn off within milliseconds like you said, the delayed off switch in UI must just be the dimming down and then UI switches to off once light has fully turned off after the half second to a second of dim down timing. Thanks for all your work and probably best to disregard my previous comment and slight oversight of this dim-down timing. Has probably been like this all along except I got nit picky after checking for bugs after the previous minor bugs. Keep up the great work and sending appreciation from all the Hue->HA users to you!

ballakers commented 2 years ago

I actually have the issue that only some lights persist being reported in the wrong state. E.g. All lights are off, I switch the room on (or use a hue scene), all physical lights turn on as expected. All lights are reported as "on" in home assistant, but some switch back to being reported as "off" 2-3 seconds later. Hue app shows the correct states. Could this be the same issue as discussed here or something else? Im using home assistant is, latest stable version.

You sure you're on 2021.12.3 of core? This issue has gone away and was only present in 2021.12.2 for me, rollback to 12.1 and current 12.3 working great.

gcorgnet commented 2 years ago

Same issue here. Losing connection and significant delay to update the UI after toggling lights. I am on core-2021.12.3

daniel1v commented 2 years ago

I can confirm the issue on 2021.12.3. It has definitely not gone away.

marcelveldt commented 2 years ago

We've just released an update for the aiohue library with some fixes. I was not able to reproduce the slow state changes (and my bridge has like 45 lights on it or so) but there were a couple of unhandled edge cases, especially on reconnect and multiple requests to the bridge. That is now handled much better.

Please do note that toggling grouped lights can cause a small slowdown in state update as the state derives from the underlying lights in HA.

Anyways, please test with the upcoming HA 2021.12.4 bugfix release. If you're still experiencing issues, please open a new issue report with a detailed description of the behavior you see (issue report per issue please to keep my mind sane). Thanks!!

hwacookie commented 2 years ago

This might be the wrong place to mention this, and I apologize as it probably IS the wrong place. However, I just upgraded from 2021.11.x to 2012.12.6, and my UI buttons are now showing exactly the same error. (e.g., switch on a light in the UI, UI-shows light as switched on, the light actually DOES switch on, and after a second or so the UI goes back to "switched off" state.

This didn't happen with 2021.11.

Oh, and I'm NOT using the Hue integration at all (but zigbee2mqtt).

Just wanted to leave this here in case someone stumbles over this.