Explicitly pass in the config_entry in mill coordinator (#138088)

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

View File

@ -47,9 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except TimeoutError as error:
raise ConfigEntryNotReady from error
data_coordinator = MillDataUpdateCoordinator(
hass,
mill_data_connection=mill_data_connection,
update_interval=update_interval,
hass, entry, mill_data_connection, update_interval
)
await data_coordinator.async_config_entry_first_refresh()

View File

@ -8,6 +8,7 @@ import logging
from mill import Mill
from mill_local import Mill as MillLocal
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -19,12 +20,14 @@ _LOGGER = logging.getLogger(__name__)
class MillDataUpdateCoordinator(DataUpdateCoordinator):
"""Class to manage fetching Mill data."""
config_entry: ConfigEntry
def __init__(
self,
hass: HomeAssistant,
update_interval: timedelta | None = None,
*,
config_entry: ConfigEntry,
mill_data_connection: Mill | MillLocal,
update_interval: timedelta,
) -> None:
"""Initialize global Mill data updater."""
self.mill_data_connection = mill_data_connection
@ -32,6 +35,7 @@ class MillDataUpdateCoordinator(DataUpdateCoordinator):
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_method=mill_data_connection.fetch_heater_and_sensor_data,
update_interval=update_interval,