Add common reolink entity description (#104142)
Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
parent
dd00357e9c
commit
69af4c8603
10 changed files with 109 additions and 99 deletions
|
@ -25,16 +25,18 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
|
||||
from . import ReolinkData
|
||||
from .const import DOMAIN
|
||||
from .entity import ReolinkChannelCoordinatorEntity
|
||||
from .entity import ReolinkChannelCoordinatorEntity, ReolinkChannelEntityDescription
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class ReolinkBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||
class ReolinkBinarySensorEntityDescription(
|
||||
BinarySensorEntityDescription,
|
||||
ReolinkChannelEntityDescription,
|
||||
):
|
||||
"""A class that describes binary sensor entities."""
|
||||
|
||||
icon_off: str = "mdi:motion-sensor-off"
|
||||
icon: str = "mdi:motion-sensor"
|
||||
supported: Callable[[Host, int], bool] = lambda host, ch: True
|
||||
value: Callable[[Host, int], bool]
|
||||
|
||||
|
||||
|
@ -128,8 +130,8 @@ class ReolinkBinarySensorEntity(ReolinkChannelCoordinatorEntity, BinarySensorEnt
|
|||
entity_description: ReolinkBinarySensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize Reolink binary sensor."""
|
||||
super().__init__(reolink_data, channel)
|
||||
self.entity_description = entity_description
|
||||
super().__init__(reolink_data, channel)
|
||||
|
||||
if self._host.api.model in DUAL_LENS_DUAL_MOTION_MODELS:
|
||||
if entity_description.translation_key is not None:
|
||||
|
@ -138,10 +140,6 @@ class ReolinkBinarySensorEntity(ReolinkChannelCoordinatorEntity, BinarySensorEnt
|
|||
key = entity_description.key
|
||||
self._attr_translation_key = f"{key}_lens_{self._channel}"
|
||||
|
||||
self._attr_unique_id = (
|
||||
f"{self._host.unique_id}_{self._channel}_{entity_description.key}"
|
||||
)
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
"""Icon of the sensor."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue