Add a calendar entity to Ridwell (#86117)
This commit is contained in:
parent
e1a5d5a749
commit
16a5275461
10 changed files with 131 additions and 25 deletions
|
@ -1,8 +1,12 @@
|
|||
"""Define a base Ridwell entity."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
|
||||
from aioridwell.model import RidwellAccount, RidwellPickupEvent
|
||||
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -18,7 +22,6 @@ class RidwellEntity(CoordinatorEntity[RidwellDataUpdateCoordinator]):
|
|||
self,
|
||||
coordinator: RidwellDataUpdateCoordinator,
|
||||
account: RidwellAccount,
|
||||
description: EntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(coordinator)
|
||||
|
@ -31,10 +34,12 @@ class RidwellEntity(CoordinatorEntity[RidwellDataUpdateCoordinator]):
|
|||
manufacturer="Ridwell",
|
||||
name="Ridwell",
|
||||
)
|
||||
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]
|
||||
return next(
|
||||
event
|
||||
for event in self.coordinator.data[self._account.account_id]
|
||||
if event.pickup_date >= date.today()
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue