Explicitly pass in the config_entry in nws coordinator (#138063)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 16:33:13 +01:00 committed by GitHub
parent 9d6b031bf9
commit d66ac97c34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -101,10 +101,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: NWSConfigEntry) -> bool:
return update_forecast_hourly
coordinator_observation = NWSObservationDataUpdateCoordinator(
hass,
nws_data,
)
coordinator_observation = NWSObservationDataUpdateCoordinator(hass, entry, nws_data)
# Don't use retries in setup
coordinator_forecast = TimestampDataUpdateCoordinator(

View File

@ -1,7 +1,10 @@
"""The NWS coordinator."""
from __future__ import annotations
from datetime import datetime
import logging
from typing import TYPE_CHECKING
from aiohttp import ClientResponseError
from pynws import NwsNoDataError, SimpleNWS, call_with_retry
@ -14,6 +17,9 @@ from homeassistant.helpers.update_coordinator import (
)
from homeassistant.util.dt import utcnow
if TYPE_CHECKING:
from . import NWSConfigEntry
from .const import (
DEBOUNCE_TIME,
DEFAULT_SCAN_INTERVAL,
@ -29,9 +35,12 @@ _LOGGER = logging.getLogger(__name__)
class NWSObservationDataUpdateCoordinator(TimestampDataUpdateCoordinator[None]):
"""Class to manage fetching NWS observation data."""
config_entry: NWSConfigEntry
def __init__(
self,
hass: HomeAssistant,
config_entry: NWSConfigEntry,
nws: SimpleNWS,
) -> None:
"""Initialize."""
@ -42,6 +51,7 @@ class NWSObservationDataUpdateCoordinator(TimestampDataUpdateCoordinator[None]):
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=f"NWS observation station {nws.station}",
update_interval=DEFAULT_SCAN_INTERVAL,
request_refresh_debouncer=debounce.Debouncer(