Add Reolink PTZ patrol start/stop (#112129)

This commit is contained in:
starkillerOG 2024-03-03 23:13:40 +01:00 committed by GitHub
parent d6cbadba3e
commit 68f17b5eab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View file

@ -419,6 +419,9 @@
"gaurd_return": {
"name": "Guard return"
},
"ptz_patrol": {
"name": "PTZ patrol"
},
"email": {
"name": "Email on event"
},

View file

@ -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)