mirror of
https://github.com/mx42/home-assistant-ecocito.git
synced 2026-01-14 22:09:49 +01:00
feat: grab all collection events in 1 call and dispatch in several sensors after
It becomes a bit of a mess with a lot of dynamically named sensors, and possibly a lot of empty ones. It adds a bit of a burden on the user to clean-up the mess. :/
This commit is contained in:
@@ -64,21 +64,18 @@ class CollectionDataUpdateCoordinator(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
client: EcocitoClient,
|
||||
year_offset: int,
|
||||
coll_type_id: int,
|
||||
refresh_time: int
|
||||
) -> None:
|
||||
"""Initialize the coordinator."""
|
||||
self.cached: dict[str, dict[str, list[CollectionEvent]]] | None = None
|
||||
super().__init__(hass, client, refresh_time)
|
||||
self._year_offset = year_offset
|
||||
self._coll_type_id = coll_type_id
|
||||
|
||||
async def _fetch_data(self) -> list[CollectionEvent]:
|
||||
"""Fetch the data."""
|
||||
return await self.client.get_collection_events(
|
||||
str(self._coll_type_id),
|
||||
datetime.now(tz=self._time_zone).year + self._year_offset,
|
||||
)
|
||||
if self.cached is None:
|
||||
self.cached = await self.client.get_collection_events(datetime.now(tz=self._time_zone).year)
|
||||
|
||||
return self.cached
|
||||
|
||||
|
||||
class WasteDepotVisitsDataUpdateCoordinator(
|
||||
|
||||
Reference in New Issue
Block a user