mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Explicitly pass in the config_entry in nws coordinator (#138063)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
9d6b031bf9
commit
d66ac97c34
@ -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(
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user