Explicitly pass in the config_entry in moehlenhoff_alpha2 coordinator (#138083)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 16:34:17 +01:00 committed by GitHub
parent 020e8fe939
commit fa1a03ded1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,7 @@ PLATFORMS = [Platform.BINARY_SENSOR, Platform.BUTTON, Platform.CLIMATE, Platform
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
base = Alpha2Base(entry.data[CONF_HOST])
coordinator = Alpha2BaseCoordinator(hass, base)
coordinator = Alpha2BaseCoordinator(hass, entry, base)
await coordinator.async_config_entry_first_refresh()

View File

@ -8,6 +8,7 @@ import logging
import aiohttp
from moehlenhoff_alpha2 import Alpha2Base
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -20,12 +21,17 @@ UPDATE_INTERVAL = timedelta(seconds=60)
class Alpha2BaseCoordinator(DataUpdateCoordinator[dict[str, dict]]):
"""Keep the base instance in one place and centralize the update."""
def __init__(self, hass: HomeAssistant, base: Alpha2Base) -> None:
config_entry: ConfigEntry
def __init__(
self, hass: HomeAssistant, config_entry: ConfigEntry, base: Alpha2Base
) -> None:
"""Initialize Alpha2Base data updater."""
self.base = base
super().__init__(
hass=hass,
logger=_LOGGER,
config_entry=config_entry,
name="alpha2_base",
update_interval=UPDATE_INTERVAL,
)