Further generalize base Ridwell entity (#85486)
This commit is contained in:
parent
5fdf78ed30
commit
5d7f33ad76
5 changed files with 61 additions and 61 deletions
34
homeassistant/components/ridwell/entity.py
Normal file
34
homeassistant/components/ridwell/entity.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
"""Define a base Ridwell entity."""
|
||||
from aioridwell.model import RidwellAccount, RidwellPickupEvent
|
||||
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
|
||||
class RidwellEntity(
|
||||
CoordinatorEntity[DataUpdateCoordinator[dict[str, RidwellPickupEvent]]]
|
||||
):
|
||||
"""Define a base Ridwell entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: DataUpdateCoordinator,
|
||||
account: RidwellAccount,
|
||||
description: EntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._account = account
|
||||
self._attr_unique_id = f"{account.account_id}_{description.key}"
|
||||
self.entity_description = description
|
||||
|
||||
@property
|
||||
def next_pickup_event(self) -> RidwellPickupEvent:
|
||||
"""Get the next pickup event."""
|
||||
return self.coordinator.data[self._account.account_id]
|
Loading…
Add table
Add a link
Reference in a new issue