Skip to content

Event listener dies: KeyError 'id' in _get_ring_event — some Ring FCM payloads no longer contain ding.id #537

Open

Description

@portsparky

Describe the bug

Since roughly 2026-07-19 (worsening through late July), some Ring FCM push notifications arrive with an event.ding object that has no id key. _get_ring_event() crashes on every such message, and after 3 sequential callback errors firebase_messaging shuts the push receiver down entirely — killing realtime events for all devices until the listener is restarted.

ERROR (MainThread) [firebase_messaging.fcmpushclient] Unexpected exception calling notification callback
Traceback (most recent call last):
  File ".../firebase_messaging/fcmpushclient.py", line 456, in _handle_data_message
    self.callback(ret_val, msg.persistent_id, self.callback_context)
  File ".../ring_doorbell/listen/eventlistener.py", line 297, in _on_notification
    ring_event = self._get_ring_event(msg_data)
  File ".../ring_doorbell/listen/eventlistener.py", line 323, in _get_ring_event
    event_id = int(event["ding"]["id"])
                   ~~~~~~~~~~~~~^^^^^^
KeyError: 'id'
ERROR (MainThread) [firebase_messaging.fcmpushclient] Shutting down push receiver due to 3 sequential errors of type ErrorType.NOTIFY

Environment

  • ring-doorbell 0.9.14 (via Home Assistant 2026.7.4, Python 3.14)
  • 13 Ring cameras (mix of battery + wired, indoor + outdoor)

Observations

  • Restarting the listener (reloading the HA integration) restores push, but it dies again within ~1–2 h once more id-less payloads arrive. 70+ occurrences of this exact traceback in the last few days of logs.
  • It appears device/notification-type dependent: two cameras stopped registering push events entirely around Jul 19 (their motions seemingly always produce the new payload), while other cameras continued working between crashes.
  • Current master still has the unguarded access at the same line, so this affects the latest code too.

Suggested fix

Treat a missing ding.id defensively in _get_ring_event (e.g. event["ding"].get("id"), falling back to a synthetic id or skipping with a debug log) so one unexpected payload variant cannot take down the whole receiver. I have debug logging enabled and will attach a sanitised capture of the offending payload when the next one lands.

Activity

  1. Robo611211 commented on Sep 17, 2026

    @Robo611211

    Confirmed here as well on Home Assistant Core 2026.9.2 / Home Assistant Green / Python 3.14.

    I reproduced the same failure with multiple Ring cameras.

    After restarting Home Assistant, the Ring event listener starts successfully and the first motion event is received normally. A subsequent FCM notification produces the same traceback:

    ERROR [firebase_messaging.fcmpushclient] Unexpected exception calling notification callback

    File ".../ring_doorbell/listen/eventlistener.py", line 297, in _on_notification
    ring_event = self._get_ring_event(msg_data)
    File ".../ring_doorbell/listen/eventlistener.py", line 323, in _get_ring_event
    event_id = int(event["ding"]["id"])
    ~~~~~~~~~~~~~^^^^^^
    KeyError: 'id'

    After this occurs, real-time motion events eventually stop being received from all Ring cameras.

    I also verified outbound FCM connectivity from the HA host:

    nc -vz mtalk.google.com 5228
    Result: port 5228 open.

    The normal Ring REST coordinator continues polling successfully after the callback exception, so the issue appears isolated to FCM notification parsing/event handling.

    Restarting Home Assistant restores real-time events temporarily.

    I have a sanitized debug capture if additional information would be useful.

  2. marc914 commented on Oct 3, 2026

    @marc914

    Same issue here. Would love to see this fixed

  3. aesherman commented on Oct 9, 2026

    @aesherman

    Confirming on Home Assistant Core 2026.10.0 (HAOS 18.3, Python 3.14) with ring-doorbell 0.9.14 and 7 Ring cameras. Same traceback, and the same Shutting down push receiver due to 3 sequential errors within seconds of every start.

    Some details that may help with #540 / #556:

    Which messages fail. I logged the shape of every push that raised (field names and types only). All 36 failures over about 50 minutes had android_config.category = com.ring.pn.live-event.motion, with ding.subtype = motion and ding.detection_type = motion. I did not capture a doorbell press, so I can't say whether dings are affected.

    What those messages contain. event.ding has no id, but the event carries other identifiers:

    data.event
      ding:         created_at, subtype, detection_type        <- no "id"
      eventito:     type, timestamp (int)
      riid:         str
      is_sidewalk, description_provider
      live_session: active_streaming_profile, default_audio_route, max_duration
    data.device:    id, kind, name, e2ee_enabled, e2ee_cem
    data.location:  id
    top level:      android_config, analytics, img, video, version
    

    Workaround that works here. Falling back to event.eventito.timestamp when ding.id is missing, and catching parse errors in _on_notification so a single unreadable message cannot trip the three-strikes shutdown:

    @@ def _on_notification
             else:
    -            ring_event = self._get_ring_event(msg_data)
    +            try:
    +                ring_event = self._get_ring_event(msg_data)
    +            except (KeyError, TypeError, ValueError) as ex:
    +                _logger.warning("Ignoring a Ring push message that could not be read (%r)", ex)
    +                ring_event = None
    @@ def _get_ring_event
    -        event_id = int(event["ding"]["id"])
             created_at = event["ding"]["created_at"]
             create_seconds = parse_datetime(created_at).timestamp()
    +        raw_id = event["ding"].get("id")
    +        if raw_id is None:
    +            raw_id = (event.get("eventito") or {}).get("timestamp") or int(create_seconds * 1000)
    +        event_id = int(raw_id)

    With that applied, motion events reach Home Assistant again (the event.*_motion entities update on each push) and the receiver has stayed up. I have not checked whether a timestamp-derived id interacts badly with _check_is_update.

  4. stefanhesslerwach commented on Oct 10, 2026

    @stefanhesslerwach

    Same issue here since 2026-10-08 ~19:00 CEST, with Home Assistant Core 2026.10 (HAOS, Python 3.14, ring-doorbell 0.9.14).

    All Ring event entities (motion/ding) stopped updating for all cameras at the same time, while the Ring app still shows the events. Polling sensors (last activity, battery) keep working.

    Log:
    Unexpected exception calling notification callback
    File ".../ring_doorbell/listen/eventlistener.py", line 297, in _on_notification
    ring_event = self._get_ring_event(msg_data)
    File ".../ring_doorbell/listen/eventlistener.py", line 323, in _get_ring_event
    event_id = int(event["ding"]["id"])
    KeyError: 'id'

    followed by:
    Shutting down push receiver due to 3 sequential errors

    What I tried without success: reloading the integration, full HA restart, reconfigure/re-authentication, removing old "ring-doorbell:HomeAssistant" authorized client devices, toggling Motion Warning in the Ring app.

    A guard like event["ding"].get("id") would probably already prevent the receiver from shutting down. Happy to provide more logs if needed.

  5. tande-roll commented on Oct 10, 2026

    @tande-roll

    Confirming on Home Assistant 2026.9.4 (HAOS 18.3, Python 3.14, ring-doorbell 0.9.14).

    Until #540 or #556 is merged and released, here's a workaround for Home Assistant users that doesn't edit site-packages, so it survives HA updates. It has 10 days of production results behind it.

    Results, 2026-09-30 → 2026-10-10 (front doorbell)

    • 148 events delivered by push (142 motion, 6 ding).
    • All 60 activities picked up by REST polling (sensor.*_last_activity) had a matching push event within 10 s. None missed.
    • Zero Unexpected exception calling notification callback.
    • The receiver shut down twice on 10-09, both ErrorType.CONNECTION (network), not this bug. A config-entry reload brought it straight back.

    For comparison, before the workaround the same setup logged 41 callback exceptions and 14 receiver shutdowns in ~34 hours, and no push events reached HA.

    How it works

    A small custom integration patches RingEventListener._get_ring_event at startup. When ding.id is missing it fills in a deterministic id (SHA-1 of device id + created_at + subtype), so repeat deliveries of the same event are still flagged is_update. It then calls the original method. Payloads that already have an id pass through untouched. If the shim itself throws, the message goes through unchanged, so the worst case is today's behaviour.

    Install: create the two files below in config/custom_components/ring_push_fix/, add ring_push_fix: on its own line in configuration.yaml, and restart. You should see ring_push_fix: applied at WARNING in the log. Delete both once HA ships a ring-doorbell release with the fix.

    manifest.json
    {
      "domain": "ring_push_fix",
      "name": "Ring Push Fix",
      "documentation": "https://github.com/python-ring-doorbell/python-ring-doorbell/issues/537",
      "codeowners": [],
      "dependencies": [],
      "requirements": [],
      "iot_class": "local_push",
      "version": "1.0.0"
    }
    __init__.py
    """Ring push fix - workaround for python-ring-doorbell issue #537.
    
    Ring began sending some FCM push payloads whose event.ding object has no
    "id" key. ring-doorbell 0.9.14 does `int(event["ding"]["id"])` unguarded, so
    each one raises KeyError. After three sequential callback failures the
    underlying firebase_messaging client shuts the push receiver down, and
    realtime doorbell and motion events stop reaching Home Assistant entirely.
    
    This patches RingEventListener._get_ring_event to repair an incomplete ding
    payload (synthetic deterministic id, and fallbacks for created_at/subtype)
    before delegating to the original implementation. If anything about the shim
    fails it passes the message through untouched, so worst case is the original
    behaviour.
    
    REMOVE THIS once upstream ships a fix and Home Assistant picks up the new
    ring-doorbell version.
    https://github.com/python-ring-doorbell/python-ring-doorbell/issues/537
    """
    
    from __future__ import annotations
    
    import hashlib
    import json
    import logging
    from datetime import datetime, timezone
    
    _LOGGER = logging.getLogger(__name__)
    
    DOMAIN = "ring_push_fix"
    _PATCH_FLAG = "_ring_push_fix_applied"
    
    
    def _synthetic_id(device: dict, ding: dict) -> int:
        """Deterministic stand-in id so repeat deliveries dedupe consistently."""
        basis = "|".join(
            str(x)
            for x in (
                device.get("id", ""),
                ding.get("created_at", ""),
                ding.get("subtype", ""),
                ding.get("kind", ""),
            )
        )
        return int(hashlib.sha1(basis.encode("utf-8")).hexdigest()[:12], 16)
    
    
    def apply_patch() -> str:
        """Patch the class method. Safe to call more than once."""
        from ring_doorbell.listen import eventlistener as el
    
        cls = el.RingEventListener
        if getattr(cls, _PATCH_FLAG, False):
            return "already applied"
    
        original = cls._get_ring_event
    
        def _get_ring_event(self, msg_data):
            try:
                data_str = msg_data.get("data")
                if data_str is not None:
                    data = json.loads(data_str)
                    event = data.get("event") or {}
                    ding = event.get("ding")
                    if isinstance(ding, dict):
                        missing = [
                            k for k in ("id", "created_at", "subtype") if k not in ding
                        ]
                        if missing:
                            if "created_at" in missing:
                                ding["created_at"] = datetime.now(timezone.utc).isoformat()
                            if "subtype" in missing:
                                ding["subtype"] = ""
                            if "id" in missing:
                                ding["id"] = _synthetic_id(data.get("device") or {}, ding)
                            _LOGGER.debug(
                                "ring_push_fix: repaired ding payload, filled %s", missing
                            )
                            msg_data = dict(msg_data)
                            msg_data["data"] = json.dumps(data)
                    elif event:
                        _LOGGER.debug(
                            "ring_push_fix: push event carries no ding object, skipping"
                        )
                        return None
            except Exception:
                _LOGGER.exception(
                    "ring_push_fix: shim errored, passing message through unchanged"
                )
    
            return original(self, msg_data)
    
        cls._get_ring_event = _get_ring_event
        setattr(cls, _PATCH_FLAG, True)
        return "applied"
    
    
    async def async_setup(hass, config) -> bool:
        try:
            result = await hass.async_add_executor_job(apply_patch)
            _LOGGER.warning(
                "ring_push_fix: %s - workaround for python-ring-doorbell issue 537",
                result,
            )
        except Exception:
            _LOGGER.exception("ring_push_fix: could not apply patch")
        return True

    What didn't help

    Clearing listen_token from the Ring config entry to force a brand-new FCM registration. Push resumed immediately, then died on the next real event. At least here it isn't a stuck backlog; the id-less payloads are just normal traffic now.

    If you're also running a reload watchdog

    HA doesn't fire system_log_event unless you set

    system_log:
      fire_event: true

    Without it, an automation triggered on Shutting down push receiver never runs. Mine silently did nothing for days before I checked the traces.

  6. stefanhesslerwach commented on Oct 10, 2026

    @stefanhesslerwach

    @tande-roll thank you so much for the workaround and the detailed write-up! I just installed ring_push_fix on HA 2026.10.1 (HA Green) and the log shows "ring_push_fix: applied". I'll report back in a day or two whether motion events reach HA reliably again.

  7. stefanhesslerwach commented on Oct 11, 2026

    @stefanhesslerwach

    Thanks a lot @tande-roll for the ring_push_fix workaround!

    Feedback from my side: installed it as a custom component on Home Assistant Green (HA 2026.10.1). The log shows "ring_push_fix: applied" after restart.

    Push events have been working reliably again since Oct 10: motion events from 6 cameras and ding events from the doorbell arrive in HA within seconds. No more KeyError: 'id' in the log.

    Before the fix, push events stopped completely after a few errors and only the polled "last activity" sensors kept updating.

    Hope this helps until the proper fix (#540 / #556) gets merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions