Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ring_doorbell/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def from_name(name: str) -> RingCapability:
DOORBELL_PRO_2_KINDS = ["lpd_v4"]
DOORBELL_ELITE_KINDS = ["jbox_v1"]
DOORBELL_WIRED_KINDS = ["doorbell_graham_cracker"]
DOORBELL_WIRED_PLUS_2_KINDS = ["cocoa_doorbell_v4w"]
DOORBELL_BATTERY_KINDS = ["df_doorbell_clownfish"]
PEEPHOLE_CAM_KINDS = ["doorbell_portal"]
DOORBELL_GEN2_KINDS = ["cocoa_doorbell", "cocoa_doorbell_v2"]
Expand Down
8 changes: 6 additions & 2 deletions ring_doorbell/doorbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
DOORBELL_VOL_MAX,
DOORBELL_VOL_MIN,
DOORBELL_WIRED_KINDS,
DOORBELL_WIRED_PLUS_2_KINDS,
DOORBELLS_ENDPOINT,
FILE_EXISTS,
HEALTH_DOORBELL_ENDPOINT,
Expand Down Expand Up @@ -80,7 +81,7 @@ async def async_update_health_data(self) -> None:
self._health_attrs = resp.json().get("device_health", {})

@property
def model(self) -> str: # noqa: C901, PLR0911
def model(self) -> str: # noqa: C901, PLR0911, PLR0912
"""Return Ring device model name."""
if self.kind in DOORBELL_KINDS:
return "Doorbell"
Expand All @@ -100,6 +101,8 @@ def model(self) -> str: # noqa: C901, PLR0911
return "Doorbell Elite"
if self.kind in DOORBELL_WIRED_KINDS:
return "Doorbell Wired"
if self.kind in DOORBELL_WIRED_PLUS_2_KINDS:
return "Wired Doorbell Plus (2nd Gen)"
if self.kind in DOORBELL_BATTERY_KINDS:
return "Battery Doorbell"
if self.kind in DOORBELL_GEN2_KINDS:
Expand Down Expand Up @@ -129,7 +132,7 @@ def has_capability(self, capability: RingCapability | str) -> bool: # noqa: PLR
if capability == RingCapability.KNOCK:
return self.kind in PEEPHOLE_CAM_KINDS
if capability == RingCapability.PRE_ROLL:
return self.kind in DOORBELL_3_PLUS_KINDS
return self.kind in (DOORBELL_3_PLUS_KINDS + DOORBELL_WIRED_PLUS_2_KINDS)
if capability == RingCapability.VOLUME:
return True
if capability == RingCapability.HISTORY:
Expand All @@ -148,6 +151,7 @@ def has_capability(self, capability: RingCapability | str) -> bool: # noqa: PLR
+ DOORBELL_PRO_KINDS
+ DOORBELL_PRO_2_KINDS
+ DOORBELL_WIRED_KINDS
+ DOORBELL_WIRED_PLUS_2_KINDS
+ DOORBELL_BATTERY_KINDS
+ DOORBELL_GEN2_KINDS
+ DOORBELL_ELITE_KINDS
Expand Down
21 changes: 21 additions & 0 deletions tests/test_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ async def test_doorbell_attributes(ring):
assert dev.wifi_signal_strength == -58


def test_wired_doorbell_plus_2_attributes(ring):
dev = ring.devices()["doorbots"][0]
dev._attrs["kind"] = "cocoa_doorbell_v4w"
dev._attrs["battery_life"] = None
dev._attrs["external_connection"] = True
dev._attrs["health"] = {"ac_power": 1}
dev._attrs["settings"]["preroll_enabled"] = True
dev._attrs["settings"]["power_mode"] = "wired"

assert dev.model == "Wired Doorbell Plus (2nd Gen)"
assert dev.battery_life is None
assert dev.has_capability("battery") is False
assert dev.has_capability("ding") is True
assert dev.has_capability("history") is True
assert dev.has_capability("knock") is False
assert dev.has_capability("motion_detection") is True
assert dev.has_capability("pre_roll") is True
assert dev.has_capability("video") is True
assert dev.has_capability("volume") is True


def test_shared_doorbell_attributes(ring):
data = ring.devices()
dev = data["authorized_doorbots"][0]
Expand Down