Repository navigation
Conversation
…yError
Ring devices can report chime_settings types outside the known
{0: Mechanical, 1: Digital, 2: Not Present} mapping (e.g. type 5 on
Ring Doorbell 4 / doorbell_oyster, type 3 on cocoa_doorbell_v3).
The unguarded dict lookup in existing_doorbell_type raised KeyError,
which in Home Assistant aborts setup of the entire switch platform.
Use .get(dtype) so unknown values return None; all callers already
guard on a falsy value, so the in-home-chime switch is simply not
created instead of crashing the platform.
Fixes python-ring-doorbell#542
…orbell#542) On devices reporting chime type 3 or 5 the tolerant getter returns None, which made the in-home-chime setters silently succeed without sending any update while the CLI still printed success. Validate the device's current chime type up front in all three setters and raise RingError for a present but unsupported type, so a skipped update can no longer be mistaken for success. A missing type keeps its existing silent no-op; known types 0/1/2 are unchanged. Add setter coverage for types 3 and 5 (no PUT sent, RingError raised) plus a direct CLI test proving no success message is printed.
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.
Fixes #542
Problem
existing_doorbell_typedoes a direct dict lookup,DOORBELL_EXISTING_TYPE[dtype], so an unknown chime type raisesKeyError. For a Ring Doorbell 4 (doorbell_oyster) reporting type 5, that takes down the entire Home Assistant switch platform during setup. The same lookup also raises for type 3 (see #543).Fix
.get(dtype)inexisting_doorbell_type, so unknown types returnNoneinstead of raising. The in-home-chime switch is simply not created for an unknown type, and the rest of the platform keeps working. No map entries were invented._validate_existing_doorbell_type()runs first in all three setters (async_set_existing_doorbell_type,_enabled,_duration). A present-but-unknown current type now raisesRingError("Unsupported existing doorbell type: {dtype}")before any request is made, instead of silently succeeding. A missing type keeps its existing silent no-op, and known types 0/1/2 are unchanged.Tests
KeyError: 3/KeyError: 5on master and returnNonewith the fix.ring_doorbellclean.Edge cases
TypeError— a pre-existing malformed-data limitation, out of scope here.Disclosure: I used AI assistance to implement and review this fix; the reproduction and tests above were run locally by me.