mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Explicitly pass in the config_entry in aurora coordinator init (#137714)
explicitly pass in the config_entry in aurora coordinator init
This commit is contained in:
parent
92234f86e8
commit
4893cdaa80
@ -1,20 +1,17 @@
|
|||||||
"""The aurora component."""
|
"""The aurora component."""
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import CONF_THRESHOLD, DEFAULT_THRESHOLD
|
from .const import CONF_THRESHOLD, DEFAULT_THRESHOLD
|
||||||
from .coordinator import AuroraDataUpdateCoordinator
|
from .coordinator import AuroraConfigEntry, AuroraDataUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||||
|
|
||||||
type AuroraConfigEntry = ConfigEntry[AuroraDataUpdateCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: AuroraConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: AuroraConfigEntry) -> bool:
|
||||||
"""Set up Aurora from a config entry."""
|
"""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()
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import AuroraConfigEntry
|
from .coordinator import AuroraConfigEntry
|
||||||
from .entity import AuroraEntity
|
from .entity import AuroraEntity
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,11 +4,11 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from aiohttp import ClientError
|
from aiohttp import ClientError
|
||||||
from auroranoaa import AuroraForecast
|
from auroranoaa import AuroraForecast
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
|
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
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
|
from .const import CONF_THRESHOLD, DEFAULT_THRESHOLD
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from . import AuroraConfigEntry
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
type AuroraConfigEntry = ConfigEntry[AuroraDataUpdateCoordinator]
|
||||||
|
|
||||||
|
|
||||||
class AuroraDataUpdateCoordinator(DataUpdateCoordinator[int]):
|
class AuroraDataUpdateCoordinator(DataUpdateCoordinator[int]):
|
||||||
"""Class to manage fetching data from the NOAA Aurora API."""
|
"""Class to manage fetching data from the NOAA Aurora API."""
|
||||||
|
|
||||||
config_entry: AuroraConfigEntry
|
config_entry: AuroraConfigEntry
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant) -> None:
|
def __init__(self, hass: HomeAssistant, config_entry: AuroraConfigEntry) -> None:
|
||||||
"""Initialize the data updater."""
|
"""Initialize the data updater."""
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass=hass,
|
hass=hass,
|
||||||
logger=_LOGGER,
|
logger=_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name="Aurora",
|
name="Aurora",
|
||||||
update_interval=timedelta(minutes=5),
|
update_interval=timedelta(minutes=5),
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@ from homeassistant.const import PERCENTAGE
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import AuroraConfigEntry
|
from .coordinator import AuroraConfigEntry
|
||||||
from .entity import AuroraEntity
|
from .entity import AuroraEntity
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user