mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Add multiple cmd_id pushes for Reolink floodlight (#146685)
Allow for multiple cmd_id pushes
This commit is contained in:
parent
2862f76fca
commit
b4af9a31cb
@ -24,7 +24,7 @@ class ReolinkEntityDescription(EntityDescription):
|
||||
"""A class that describes entities for Reolink."""
|
||||
|
||||
cmd_key: str | None = None
|
||||
cmd_id: int | None = None
|
||||
cmd_id: int | list[int] | None = None
|
||||
always_available: bool = False
|
||||
|
||||
|
||||
@ -120,11 +120,14 @@ class ReolinkHostCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinator[None]
|
||||
"""Entity created."""
|
||||
await super().async_added_to_hass()
|
||||
cmd_key = self.entity_description.cmd_key
|
||||
cmd_id = self.entity_description.cmd_id
|
||||
cmd_ids = self.entity_description.cmd_id
|
||||
callback_id = f"{self.platform.domain}_{self._attr_unique_id}"
|
||||
if cmd_key is not None:
|
||||
self._host.async_register_update_cmd(cmd_key)
|
||||
if cmd_id is not None:
|
||||
if isinstance(cmd_ids, int):
|
||||
self.register_callback(callback_id, cmd_ids)
|
||||
elif isinstance(cmd_ids, list):
|
||||
for cmd_id in cmd_ids:
|
||||
self.register_callback(callback_id, cmd_id)
|
||||
# Privacy mode
|
||||
self.register_callback(f"{callback_id}_623", 623)
|
||||
|
@ -57,7 +57,7 @@ LIGHT_ENTITIES = (
|
||||
ReolinkLightEntityDescription(
|
||||
key="floodlight",
|
||||
cmd_key="GetWhiteLed",
|
||||
cmd_id=291,
|
||||
cmd_id=[291, 289, 438],
|
||||
translation_key="floodlight",
|
||||
supported=lambda api, ch: api.supported(ch, "floodLight"),
|
||||
is_on_fn=lambda api, ch: api.whiteled_state(ch),
|
||||
|
@ -113,6 +113,7 @@ NUMBER_ENTITIES = (
|
||||
ReolinkNumberEntityDescription(
|
||||
key="floodlight_brightness",
|
||||
cmd_key="GetWhiteLed",
|
||||
cmd_id=[289, 438],
|
||||
translation_key="floodlight_brightness",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
native_step=1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user