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
This commit is contained in:
parent
0582c39d33
commit
ee7bee2766
14 changed files with 479 additions and 385 deletions
|
@ -2,12 +2,10 @@
|
|||
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import ATTRIBUTION, CONF_FLIPR_ID, DOMAIN, MANUFACTURER
|
||||
from .const import ATTRIBUTION, DOMAIN, MANUFACTURER
|
||||
from .coordinator import FliprDataUpdateCoordinator
|
||||
|
||||
|
||||
class FliprEntity(CoordinatorEntity):
|
||||
|
@ -17,17 +15,21 @@ class FliprEntity(CoordinatorEntity):
|
|||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self, coordinator: DataUpdateCoordinator, description: EntityDescription
|
||||
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
|
||||
if coordinator.config_entry:
|
||||
flipr_id = coordinator.config_entry.data[CONF_FLIPR_ID]
|
||||
self._attr_unique_id = f"{flipr_id}-{description.key}"
|
||||
self._attr_unique_id = f"{self.device_id}-{description.key}"
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, flipr_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=f"Flipr {flipr_id}",
|
||||
)
|
||||
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}",
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue