Track FCM receiver health in the event listener - #555
Open
thomasgregg wants to merge 1 commit into
Open
thomasgregg wants to merge 1 commit into
thomasgregg wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RingEventListener.startedreflect the FCM receiver's actual logged-in state.1.Why
FcmPushClient.start()schedules its background tasks and returns before MCS login.RingEventListenercurrently sets an independentstarted = Trueimmediately afterward. If login never succeeds, or if the receiver later terminates after repeated errors, the Ring listener can continue to report that it is started even though no notifications can arrive.That stale state is the failure described in #526: downstream callers cannot distinguish “no event occurred” from “the receiver is dead.” It also makes a safe retry difficult because overlapping starts can add duplicate internal callbacks and leave partial state behind.
After this change, startup succeeds only after
FcmPushClient.is_started()confirms login. The publicstartedproperty then follows that receiver health, so a later receiver termination becomes visible to callers. This PR deliberately does not add an automatic retry policy; it provides the trustworthy lifecycle contract required for a caller such as Home Assistant to implement one.The callback-ID change also covers the documented usage pattern where a consumer registers its callback before calling
start(). In that order, the library's internal callback is not ID1.This does not touch push-payload parsing and therefore does not overlap with #540.
Fixes #526.
Tests
Added regression coverage for:
Full suite:
46 passed. Ruff format/lint, mypy, andgit diff --checkpass.