Explicitly pass in the config_entry in touchline_sl coordinator (#137897)
explicitly pass in the config_entry in coordinatorpull/138060/head
parent
8a7ee039d1
commit
d71a539fbc
|
@ -6,18 +6,15 @@ import asyncio
|
|||
|
||||
from pytouchlinesl import TouchlineSL
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import TouchlineSLModuleCoordinator
|
||||
from .coordinator import TouchlineSLConfigEntry, TouchlineSLModuleCoordinator
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.CLIMATE]
|
||||
|
||||
type TouchlineSLConfigEntry = ConfigEntry[list[TouchlineSLModuleCoordinator]]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: TouchlineSLConfigEntry) -> bool:
|
||||
"""Set up Roth Touchline SL from a config entry."""
|
||||
|
@ -26,7 +23,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: TouchlineSLConfigEntry)
|
|||
)
|
||||
|
||||
coordinators: list[TouchlineSLModuleCoordinator] = [
|
||||
TouchlineSLModuleCoordinator(hass, module) for module in await account.modules()
|
||||
TouchlineSLModuleCoordinator(hass, entry, module)
|
||||
for module in await account.modules()
|
||||
]
|
||||
|
||||
await asyncio.gather(
|
||||
|
|
|
@ -12,8 +12,7 @@ from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import TouchlineSLConfigEntry
|
||||
from .coordinator import TouchlineSLModuleCoordinator
|
||||
from .coordinator import TouchlineSLConfigEntry, TouchlineSLModuleCoordinator
|
||||
from .entity import TouchlineSLZoneEntity
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ from pytouchlinesl import Module, Zone
|
|||
from pytouchlinesl.client import RothAPIError
|
||||
from pytouchlinesl.client.models import GlobalScheduleModel
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -26,14 +27,22 @@ class TouchlineSLModuleData:
|
|||
schedules: dict[str, GlobalScheduleModel]
|
||||
|
||||
|
||||
type TouchlineSLConfigEntry = ConfigEntry[list[TouchlineSLModuleCoordinator]]
|
||||
|
||||
|
||||
class TouchlineSLModuleCoordinator(DataUpdateCoordinator[TouchlineSLModuleData]):
|
||||
"""A coordinator to manage the fetching of Touchline SL data."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, module: Module) -> None:
|
||||
config_entry: TouchlineSLConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, config_entry: TouchlineSLConfigEntry, module: Module
|
||||
) -> None:
|
||||
"""Initialize coordinator."""
|
||||
super().__init__(
|
||||
hass,
|
||||
logger=_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=f"Touchline SL ({module.name})",
|
||||
update_interval=timedelta(seconds=30),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue