Skip to content

fix: mark a device offline on a majority of distinct stale bridges, not on every bridge - #42

Merged
baudneo merged 2 commits into
baudneo:claude-refactorfrom
crdson93:pr/majority-of-distinct-bridges-vote
Oct 25, 2026
Merged

baudneo merged 2 commits into
baudneo:claude-refactorfrom
crdson93:pr/majority-of-distinct-bridges-vote

Conversation

@crdson93

Copy link
Copy Markdown

Part 2/4 of the split requested in #39 (comment). Depends on #41 (only new commit here is 14c7c13).

Some bridges (in my case, an always-on Cync plug) never report status for every device on the mesh, so requiring all live bridges to report a device stale means the vote can never be reached. Switches the threshold to a strict majority of distinct live bridges instead of unanimous.

crdson93 and others added 2 commits October 23, 2026 14:52
A bulb that is itself a TCP bridge and loses power can stay "on" in HA: the mesh flags it stale
~26 s after the cut, but if its dead bridge session is reaped after the other bridges' stale reports
arrive, `num_late_states >= len(pool)` was evaluated against the old, larger pool and never re-checked.

CyncTCPSession.close() now calls nCyncServer.revote_offline(), which re-runs the vote for every device
that has outstanding stale reports against the new pool size. Counted in the offline_revotes stat.

Refs baudneo#39

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ot on every bridge

Hardware run 2026-10-23 (8 live bridges, 4-bulb fixture cut at the wall): all 8 bridges reported two of the
bulbs stale, but only 7 reported the other two. The vote needed `stale reports >= len(pool)`, so those two
stayed "on" in HA indefinitely. Each bridge only reports the devices it has heard from, so "every bridge"
is not a reachable condition.

- Track the distinct bridge IPs that reported a device stale since its last valid report (`stale_voters`)
  instead of counting reports; repeat reports from one bridge no longer count twice.
- A device goes offline when a strict majority of the live bridges have voted (a lone bridge decides
  alone). Votes from disconnected bridges are ignored.
- Handler passes the reporting bridge's IP to handle_entity_update (0x83 internal status).

Refs baudneo#39

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@baudneo
baudneo merged commit ad146d5 into baudneo:claude-refactor Oct 25, 2026
1 check passed
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.

2 participants