Explicitly pass in the config_entry in aurora coordinator init (#137714)
explicitly pass in the config_entry in aurora coordinator initpull/131282/head
parent
92234f86e8
commit
4893cdaa80
|
@ -1,20 +1,17 @@
|
|||
"""The aurora component."""
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import CONF_THRESHOLD, DEFAULT_THRESHOLD
|
||||
from .coordinator import AuroraDataUpdateCoordinator
|
||||
from .coordinator import AuroraConfigEntry, AuroraDataUpdateCoordinator
|
||||
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
type AuroraConfigEntry = ConfigEntry[AuroraDataUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: AuroraConfigEntry) -> bool:
|
||||
"""Set up Aurora from a config entry."""
|
||||
coordinator = AuroraDataUpdateCoordinator(hass=hass)
|
||||
coordinator = AuroraDataUpdateCoordinator(hass=hass, config_entry=entry)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from homeassistant.components.binary_sensor import BinarySensorEntity
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import AuroraConfigEntry
|
||||
from .coordinator import AuroraConfigEntry
|
||||
from .entity import AuroraEntity
|
||||
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ from __future__ import annotations
|
|||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from aiohttp import ClientError
|
||||
from auroranoaa import AuroraForecast
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -16,23 +16,23 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
|||
|
||||
from .const import CONF_THRESHOLD, DEFAULT_THRESHOLD
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import AuroraConfigEntry
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type AuroraConfigEntry = ConfigEntry[AuroraDataUpdateCoordinator]
|
||||
|
||||
|
||||
class AuroraDataUpdateCoordinator(DataUpdateCoordinator[int]):
|
||||
"""Class to manage fetching data from the NOAA Aurora API."""
|
||||
|
||||
config_entry: AuroraConfigEntry
|
||||
|
||||
def __init__(self, hass: HomeAssistant) -> None:
|
||||
def __init__(self, hass: HomeAssistant, config_entry: AuroraConfigEntry) -> None:
|
||||
"""Initialize the data updater."""
|
||||
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name="Aurora",
|
||||
update_interval=timedelta(minutes=5),
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.const import PERCENTAGE
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import AuroraConfigEntry
|
||||
from .coordinator import AuroraConfigEntry
|
||||
from .entity import AuroraEntity
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue