From 68f17b5eab88b375ce208d392805b6124d8ac854 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Sun, 3 Mar 2024 23:13:40 +0100 Subject: [PATCH] Add Reolink PTZ patrol start/stop (#112129) --- homeassistant/components/reolink/strings.json | 3 +++ homeassistant/components/reolink/switch.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/reolink/strings.json b/homeassistant/components/reolink/strings.json index c57eec22ce5..b8525549b1d 100644 --- a/homeassistant/components/reolink/strings.json +++ b/homeassistant/components/reolink/strings.json @@ -419,6 +419,9 @@ "gaurd_return": { "name": "Guard return" }, + "ptz_patrol": { + "name": "PTZ patrol" + }, "email": { "name": "Email on event" }, diff --git a/homeassistant/components/reolink/switch.py b/homeassistant/components/reolink/switch.py index 7f57b78df1e..73f4cbc9aa4 100644 --- a/homeassistant/components/reolink/switch.py +++ b/homeassistant/components/reolink/switch.py @@ -33,7 +33,7 @@ class ReolinkSwitchEntityDescription( """A class that describes switch entities.""" method: Callable[[Host, int, bool], Any] - value: Callable[[Host, int], bool] + value: Callable[[Host, int], bool | None] @dataclass(frozen=True, kw_only=True) @@ -108,6 +108,14 @@ SWITCH_ENTITIES = ( value=lambda api, ch: api.ptz_guard_enabled(ch), method=lambda api, ch, value: api.set_ptz_guard(ch, enable=value), ), + ReolinkSwitchEntityDescription( + key="ptz_patrol", + translation_key="ptz_patrol", + icon="mdi:map-marker-path", + supported=lambda api, ch: api.supported(ch, "ptz_patrol"), + value=lambda api, ch: None, + method=lambda api, ch, value: api.ctrl_ptz_patrol(ch, value), + ), ReolinkSwitchEntityDescription( key="email", cmd_key="GetEmail", @@ -275,7 +283,7 @@ class ReolinkSwitchEntity(ReolinkChannelCoordinatorEntity, SwitchEntity): super().__init__(reolink_data, channel) @property - def is_on(self) -> bool: + def is_on(self) -> bool | None: """Return true if switch is on.""" return self.entity_description.value(self._host.api, self._channel)