Repository navigation
Conversation
- Keep refreshing the ring session every 12 hours instead of only once, and retry if a refresh fails rather than ending the refresh task. - Catch exceptions parsing push payloads so a malformed notification is logged and skipped instead of counting towards the FcmPushClient error limit. - Do not let FcmPushClient permanently shut down after 3 sequential errors; keep resetting the connection. - Fix legacy ding events being reported with the push action as their kind because str.lower was compared without being called. Related to python-ring-doorbell#526 and home-assistant/core#157764. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 of 21 tasks
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
FcmPushClient.abort_on_sequential_error_count = NoneinRingEventListenerConfig.default_config()so the push client keeps resetting the connection instead of permanently shutting down after 3 sequential errors.gcmData) ding events being reported with the push action string as theirkind:action.lower == PUSH_ACTION_DING.lower()compared the bound method rather than calling it.Why
Home Assistant users have reported for months that doorbell and motion events silently stop arriving until the integration is reloaded (home-assistant/core#157764). Tracing it shows that several unrelated failures all end in the same place: the push client stops for good.
FcmPushClientcalls_terminate()after 3 sequential errors of one type. Two of those types are relevant here:CONNECTION: e.g.SSL shutdown timed outorIncompleteReadErrorduring a brief internet outage.NOTIFY: exceptions raised by our notification callback. Since Ring started sending some notifications withoutevent.ding.id(Event listener dies: KeyError 'id' in _get_ring_event — some Ring FCM payloads no longer contain ding.id #537, Bug:KeyError: 'id'inRingEventListener._get_ring_eventon a malformed push notification #552),_get_ring_eventraisesKeyError: 'id'. Three of those in a row stop the client._periodic_session_refreshrefreshes the session and push subscription after 12 hours, thenbreaks and the task ends. After the first refresh, nothing re-subscribes the FCM token for the lifetime of the listener. Its sleep was also computed from the time elapsed since the last refresh (1 + now - refresh_time), not the time left until the next one.With the error limit disabled,
FcmPushClientkeeps calling_reset()after connection errors, and callback errors are still logged but no longer stop the client. Malformed payloads are now caught in_on_notification, so they no longer reach the client at all.This PR does not make the listener unkillable.
FcmPushClient._reset()still terminates if it cannot reconnect afterconnection_retry_countattempts, and its catch-all in_listen()still terminates on decode errors such asIncorrect padding(sdb9696/firebase-messaging#40, #44). Callers still need to be able to tell that the receiver has died, which is what #555 provides. These changes are independent of #555 and #556 and touch different code paths, so they can be merged in any order.Related to #526 and home-assistant/core#157764. Complements #555 and #556.
Tests
Added regression tests for:
kind == "ding";ding.id) being logged and skipped, with later notifications still delivered;RingError.All four new tests fail on
masterand pass with this change. Full suite:44 passed.ruff check,ruff format --checkandmypypass on the changed files.🤖 Generated with Claude Code