Further generalize base Ridwell entity (#85486)

This commit is contained in:
Aaron Bach 2023-01-10 04:15:28 -07:00 committed by GitHub
parent 5fdf78ed30
commit 5d7f33ad76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 61 deletions

View 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]