Add Reolink zoom in/out buttons (#97638)
This commit is contained in:
parent
6f7c3c949c
commit
2a78d7fa2d
1 changed files with 24 additions and 1 deletions
|
@ -36,6 +36,7 @@ class ReolinkButtonEntityDescription(
|
|||
"""A class that describes button entities for a camera channel."""
|
||||
|
||||
supported: Callable[[Host, int], bool] = lambda api, ch: True
|
||||
enabled_default: Callable[[Host, int], bool] | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -59,7 +60,9 @@ BUTTON_ENTITIES = (
|
|||
key="ptz_stop",
|
||||
name="PTZ stop",
|
||||
icon="mdi:pan",
|
||||
supported=lambda api, ch: api.supported(ch, "pan_tilt"),
|
||||
enabled_default=lambda api, ch: api.supported(ch, "pan_tilt"),
|
||||
supported=lambda api, ch: api.supported(ch, "pan_tilt")
|
||||
or api.supported(ch, "zoom_basic"),
|
||||
method=lambda api, ch: api.set_ptz_command(ch, command=PtzEnum.stop.value),
|
||||
),
|
||||
ReolinkButtonEntityDescription(
|
||||
|
@ -90,6 +93,22 @@ BUTTON_ENTITIES = (
|
|||
supported=lambda api, ch: api.supported(ch, "tilt"),
|
||||
method=lambda api, ch: api.set_ptz_command(ch, command=PtzEnum.down.value),
|
||||
),
|
||||
ReolinkButtonEntityDescription(
|
||||
key="ptz_zoom_in",
|
||||
name="PTZ zoom in",
|
||||
icon="mdi:magnify",
|
||||
entity_registry_enabled_default=False,
|
||||
supported=lambda api, ch: api.supported(ch, "zoom_basic"),
|
||||
method=lambda api, ch: api.set_ptz_command(ch, command=PtzEnum.zoomin.value),
|
||||
),
|
||||
ReolinkButtonEntityDescription(
|
||||
key="ptz_zoom_out",
|
||||
name="PTZ zoom out",
|
||||
icon="mdi:magnify",
|
||||
entity_registry_enabled_default=False,
|
||||
supported=lambda api, ch: api.supported(ch, "zoom_basic"),
|
||||
method=lambda api, ch: api.set_ptz_command(ch, command=PtzEnum.zoomout.value),
|
||||
),
|
||||
ReolinkButtonEntityDescription(
|
||||
key="ptz_calibrate",
|
||||
name="PTZ calibrate",
|
||||
|
@ -169,6 +188,10 @@ class ReolinkButtonEntity(ReolinkChannelCoordinatorEntity, ButtonEntity):
|
|||
self._attr_unique_id = (
|
||||
f"{self._host.unique_id}_{channel}_{entity_description.key}"
|
||||
)
|
||||
if entity_description.enabled_default is not None:
|
||||
self._attr_entity_registry_enabled_default = (
|
||||
entity_description.enabled_default(self._host.api, self._channel)
|
||||
)
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Execute the button action."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue