Add control entities: box to-do list, skip switch, donate button, subscriptions
The to-do list exists so Home Assistant's own conversation agent can manage the order through HassListAddItem rather than through anything bespoke. Skip is a switch because skipped/not-skipped is state worth reading back; donate is a button because it cannot be undone. Un-skip raises rather than guessing at an endpoint that has never been observed. Fixes subscription parsing, which matched the heading row and so reported zero on an account that has one.
This commit is contained in:
@@ -9,6 +9,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .actions import FreshHarvestActions
|
||||
from .api import (
|
||||
AccountSnapshot,
|
||||
FreshHarvestAuthError,
|
||||
@@ -34,10 +35,15 @@ class FreshHarvestCoordinator(DataUpdateCoordinator[AccountSnapshot]):
|
||||
config_entry=entry,
|
||||
)
|
||||
self.client = client
|
||||
self.actions = FreshHarvestActions(client)
|
||||
|
||||
async def _async_update_data(self) -> AccountSnapshot:
|
||||
try:
|
||||
return await self.client.async_get_snapshot()
|
||||
snapshot = await self.client.async_get_snapshot()
|
||||
# Two extra pages per refresh, so three requests every six hours.
|
||||
snapshot.subscriptions = await self.actions.async_list_subscriptions()
|
||||
snapshot.vacation_holds = await self.actions.async_list_vacation_holds()
|
||||
return snapshot
|
||||
except FreshHarvestAuthError as err:
|
||||
raise ConfigEntryAuthFailed(str(err)) from err
|
||||
except FreshHarvestError as err:
|
||||
|
||||
Reference in New Issue
Block a user