Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hue bugfix bridge offline every driver restart #922

Closed
wants to merge 4 commits into from

Conversation

cjswedes
Copy link
Contributor

Whenever a driver is restarted, a bridge will temporarily be marked offline while the event source connection is created. This seems to be affecting the online/offline state of children incorrectly post 0.49.x FW.

Whenever a driver is restart, a bridge will temporarily be marked
offline while the event source connection is created. This seems to be
affecting the online/offline state of children incorrectly post 0.49.x
FW.
@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Channel deleted.

@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Test Results

     52 files     336 suites   0s ⏱️
1 577 tests 1 577 ✔️ 0 💤 0
2 732 runs  2 732 ✔️ 0 💤 0

Results for commit 70b7a0e.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 70b7a0e

@cjswedes cjswedes requested a review from varzac August 21, 2023 19:22
@dljsjr
Copy link
Contributor

dljsjr commented Aug 22, 2023

I'm not 100% confident that these fixes are the correct fixes for the symptoms we're seeing but I'm fine with pushing them forward to get the release moving, if we decide that's best.

Firstly, the zigbee connectivity status isn't guaranteed to come in over a refresh. The only way this would be "fixing" things is by emitting events for lights that are connected to the bridge and so forcing an online event in that way, and the Hue bridge will gladly give you the last known state for a freshly disconnected device to get emitted. So it could be a false positive.

The "correct" fix here would be to poll the Zigbee service for the Device directly but we don't currently store that association.

Secondly, I have doubts about this statement:

Yup, you're right. Without the change any time a bridge comes online after being offline the children would erroneously remain offline rather than being queried to see if they are online.

Server-Sent Event connections are set up in such a way that if a client disconnects then reconnects, it notifies the server of the last event ID that it received, and the stream will "catch up" the client on anything it missed in the interrim: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/philips-hue/src/lunchbox/sse/eventsource.lua#L280

Granted there is an edge case somewhere in there where this statement would hold true if there was 0 activity on the SSE stream in between the disconnect and the reconnect, and this wouldn't hold for the case where the Hue Bridge itself loses power and so that state is no longer in the web server's memory. But this should be something exceedingly rare in a live system with just a hub or driver restart.

@cjswedes
Copy link
Contributor Author

Firstly, the zigbee connectivity status isn't guaranteed to come in over a refresh. The only way this would be "fixing" things is by emitting events for lights that are connected to the bridge and so forcing an online event in that way, and the Hue bridge will gladly give you the last known state for a freshly disconnected device to get emitted. So it could be a false positive.

Thanks for the clarification on how the bridge actually reports this. After discussing offline we should make a change that will poll the zigbee connectivity service for each device when the bridge is initialized (avoiding an http request flood). However, we should leave the refresh call in place because it seems that the attribute events emitted to ST cause the child devices to come online.

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.

5 participants