mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +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
|
return update_forecast_hourly
|
||||||
|
|
||||||
coordinator_observation = NWSObservationDataUpdateCoordinator(
|
coordinator_observation = NWSObservationDataUpdateCoordinator(hass, entry, nws_data)
|
||||||
hass,
|
|
||||||
nws_data,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Don't use retries in setup
|
# Don't use retries in setup
|
||||||
coordinator_forecast = TimestampDataUpdateCoordinator(
|
coordinator_forecast = TimestampDataUpdateCoordinator(
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
"""The NWS coordinator."""
|
"""The NWS coordinator."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from aiohttp import ClientResponseError
|
from aiohttp import ClientResponseError
|
||||||
from pynws import NwsNoDataError, SimpleNWS, call_with_retry
|
from pynws import NwsNoDataError, SimpleNWS, call_with_retry
|
||||||
@ -14,6 +17,9 @@ from homeassistant.helpers.update_coordinator import (
|
|||||||
)
|
)
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import NWSConfigEntry
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DEBOUNCE_TIME,
|
DEBOUNCE_TIME,
|
||||||
DEFAULT_SCAN_INTERVAL,
|
DEFAULT_SCAN_INTERVAL,
|
||||||
@ -29,9 +35,12 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class NWSObservationDataUpdateCoordinator(TimestampDataUpdateCoordinator[None]):
|
class NWSObservationDataUpdateCoordinator(TimestampDataUpdateCoordinator[None]):
|
||||||
"""Class to manage fetching NWS observation data."""
|
"""Class to manage fetching NWS observation data."""
|
||||||
|
|
||||||
|
config_entry: NWSConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: NWSConfigEntry,
|
||||||
nws: SimpleNWS,
|
nws: SimpleNWS,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
@ -42,6 +51,7 @@ class NWSObservationDataUpdateCoordinator(TimestampDataUpdateCoordinator[None]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=f"NWS observation station {nws.station}",
|
name=f"NWS observation station {nws.station}",
|
||||||
update_interval=DEFAULT_SCAN_INTERVAL,
|
update_interval=DEFAULT_SCAN_INTERVAL,
|
||||||
request_refresh_debouncer=debounce.Debouncer(
|
request_refresh_debouncer=debounce.Debouncer(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user