Add Fresh Harvest integration scaffold
Implements the freshharvest.com two-step login handshake, config flow, 6-hour polling coordinator, and four delivery sensors. Portal page parsing is not implemented; async_get_next_delivery raises until the account HTML is mapped against a signed-in session.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Polling coordinator for Fresh Harvest."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .api import Delivery, FreshHarvestAuthError, FreshHarvestClient, FreshHarvestError
|
||||
from .const import DOMAIN, UPDATE_INTERVAL
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FreshHarvestCoordinator(DataUpdateCoordinator[Delivery]):
|
||||
"""Fetch the account's next delivery."""
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, entry: ConfigEntry, client: FreshHarvestClient
|
||||
) -> None:
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
name=DOMAIN,
|
||||
update_interval=UPDATE_INTERVAL,
|
||||
config_entry=entry,
|
||||
)
|
||||
self.client = client
|
||||
|
||||
async def _async_update_data(self) -> Delivery:
|
||||
try:
|
||||
return await self.client.async_get_next_delivery()
|
||||
except FreshHarvestAuthError as err:
|
||||
raise ConfigEntryAuthFailed(str(err)) from err
|
||||
except FreshHarvestError as err:
|
||||
raise UpdateFailed(str(err)) from err
|
||||
Reference in New Issue
Block a user