Skip to content

KeyError on unknown existing_doorbell_type (5) takes down the entire HA switch platform — still present in 0.9.14 (doorbell_oyster) #542

Closed as not planned

Description

@davinoishi

Summary

Doorbot.existing_doorbell_type does an unguarded dict lookup into DOORBELL_EXISTING_TYPE, so any chime type value outside {0, 1, 2} raises KeyError. On Home Assistant this doesn't just skip one entity — it aborts setup of the entire switch platform for the Ring integration.

This was previously reported in #506 (Jan 2026) for a Battery Doorbell Plus (cocoa_doorbell_v2). That issue was auto-closed by the stale bot in April without a fix and is now locked, so I can't add to it. The related HA core issue home-assistant/core#135741 was closed as not planned.

I'm reopening the report with a different device family and with before/after measurements of the impact and the proposed fix.

Environment

ring-doorbell 0.9.14 (current PyPI release)
Home Assistant 2026.8.1 (container)
Python 3.14
Device Ring Doorbell 4 — kind: doorbell_oyster

Note this is not the cocoa_doorbell_v2 from #506, so the problem isn't confined to one device family.

Raw API data

From Home Assistant's diagnostics export for the config entry (HA's own redaction applied):

{
  "kind": "doorbell_oyster",
  "settings": {
    "chime_settings": { "enable": true, "type": 5, "duration": 10 }
  },
  "features": {
    "chime_settings": { "is_eligible": true, "auto_detect": {} },
    "chime_auto_detect_capable": true
  }
}

This supports the interpretation in #506 that 5 is an initial/unset state: it appears on a doorbell with chime_auto_detect_capable: true and an empty auto_detect block. A stickup_cam_mini on the same account reports type: 2 and behaves fine, so the trigger tracks the auto-detect capability rather than the device generation — which suggests this will affect a growing number of accounts as that hardware becomes more common.

Traceback

Error while setting up ring platform for switch: 5
Traceback (most recent call last):
  File "homeassistant/helpers/entity_platform.py", line 499, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "homeassistant/components/ring/switch.py", line 99, in async_setup_entry
    async_add_entities(
  File "homeassistant/helpers/entity_platform.py", line 618, in _async_schedule_add_entities_for_entry
    new_entities if type(new_entities) is list else list(new_entities)
  File "homeassistant/components/ring/switch.py", line 103, in <genexpr>
    if description.exists_fn(device)
  File "homeassistant/components/ring/switch.py", line 71, in <lambda>
    and device.existing_doorbell_type in IN_HOME_CHIME_IS_PRESENT
  File "ring_doorbell/doorbot.py", line 193, in existing_doorbell_type
    return DOORBELL_EXISTING_TYPE[dtype]
KeyError: 5

Why the impact is larger than #506 described

#506 characterised this as blocking the in-home chime entity. It's broader than that. In ring/switch.py, exists_fn is evaluated lazily inside the generator handed to async_add_entities, so the KeyError surfaces during list(new_entities) and propagates out of async_setup_entry. The platform never registers any of its entities — including motion_detection, which has nothing to do with chimes.

Measured on my account, one doorbell with type: 5 plus nine unrelated cameras:

switch entities registered error in log
stock 0.9.14 0 yes
with .get(dtype) 10 (9 cameras + doorbell motion_detection) none

So a single doorbell reporting an unmapped chime type removes motion-detection control for every Ring camera on the account. siren entities are unaffected — they're on the siren platform, which sets up independently.

Suggested fix

Option 2 from #506 still looks right — tolerate unknown values instead of taking the platform down:

# doorbot.py ~193
if (dtype := self._get_chime_setting("type")) is not None:
    return DOORBELL_EXISTING_TYPE.get(dtype)

I applied exactly this locally to confirm it: the switch platform sets up cleanly, all ten entities appear, and the in-home chime switch is correctly not created for the unknown type (None not in IN_HOME_CHIME_IS_PRESENT) rather than being created with a bogus state. I've since reverted it — I'm not running a patched library, just verifying the fix.

Expanding the mapping with 3 and 5 (option 1 in #506) would fix today's values, but a .get() also prevents the next unmapped value from causing the same outage. The two can of course be combined.

Happy to pull any further diagnostics from this device if useful.

Activity

  1. github-actions commented on Nov 8, 2026

    @github-actions

    There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs.
    Please make sure to update to the latest ring_doorbell version and check if that solves the issue.
    Thank you for your contributions.

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

    staleStale PRs and Issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions