hass-core/homeassistant/components/flipr/entity.py
cnico ee7bee2766
Refactoring flipr integration to prepare Hub device addition (#125262)
* Addition of hub device

* coordinator udata updated after a hub action

* Unit tests update

* Unit tests improvements

* addition of tests on select and switch platforms

* wording

* Removal of select platform for PR containing only one platform

* Remove hub to maintain only the refactoring that prepare the hub device addition

* Review corrections

* wording

* Review corrections

* Review corrections

* Review corrections
2024-09-11 23:34:29 +02:00

35 lines
1.2 KiB
Python

"""Base entity for the flipr entity."""
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import ATTRIBUTION, DOMAIN, MANUFACTURER
from .coordinator import FliprDataUpdateCoordinator
class FliprEntity(CoordinatorEntity):
"""Implements a common class elements representing the Flipr component."""
_attr_attribution = ATTRIBUTION
_attr_has_entity_name = True
def __init__(
self,
coordinator: FliprDataUpdateCoordinator,
description: EntityDescription,
is_flipr_hub: bool = False,
) -> None:
"""Initialize Flipr sensor."""
super().__init__(coordinator)
self.device_id = coordinator.device_id
self.entity_description = description
self._attr_unique_id = f"{self.device_id}-{description.key}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.device_id)},
manufacturer=MANUFACTURER,
name=f"Flipr hub {self.device_id}"
if is_flipr_hub
else f"Flipr {self.device_id}",
)