1 """Define an object to manage fetching Touchline SL data."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
6 from datetime
import timedelta
9 from pytouchlinesl
import Module, Zone
10 from pytouchlinesl.client
import RothAPIError
11 from pytouchlinesl.client.models
import GlobalScheduleModel
17 _LOGGER = logging.getLogger(__name__)
22 """Provide type safe way of accessing module data from the coordinator."""
25 zones: dict[int, Zone]
26 schedules: dict[str, GlobalScheduleModel]
30 """A coordinator to manage the fetching of Touchline SL data."""
32 def __init__(self, hass: HomeAssistant, module: Module) ->
None:
33 """Initialize coordinator."""
37 name=f
"Touchline SL ({module.name})",
44 """Fetch data from the upstream API and pre-process into the right format."""
46 zones = await self.
modulemodule.zones()
47 schedules = await self.
modulemodule.schedules()
48 except RothAPIError
as error:
49 if error.status == 401:
52 raise ConfigEntryAuthFailed
from error
57 zones={z.id: z
for z
in zones},
58 schedules={s.name: s
for s
in schedules},
TouchlineSLModuleData _async_update_data(self)
None __init__(self, HomeAssistant hass, Module module)