mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Explicitly pass in the config_entry in garages_amsterdam coordinator (#137829)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
13f6f045f5
commit
239408aa5d
@ -4,24 +4,24 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from odp_amsterdam import ODPAmsterdam
|
from odp_amsterdam import ODPAmsterdam
|
||||||
|
|
||||||
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 homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .coordinator import GaragesAmsterdamDataUpdateCoordinator
|
from .coordinator import (
|
||||||
|
GaragesAmsterdamConfigEntry,
|
||||||
|
GaragesAmsterdamDataUpdateCoordinator,
|
||||||
|
)
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||||
|
|
||||||
type GaragesAmsterdamConfigEntry = ConfigEntry[GaragesAmsterdamDataUpdateCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: GaragesAmsterdamConfigEntry
|
hass: HomeAssistant, entry: GaragesAmsterdamConfigEntry
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Set up Garages Amsterdam from a config entry."""
|
"""Set up Garages Amsterdam from a config entry."""
|
||||||
client = ODPAmsterdam(session=async_get_clientsession(hass))
|
client = ODPAmsterdam(session=async_get_clientsession(hass))
|
||||||
coordinator = GaragesAmsterdamDataUpdateCoordinator(hass, client)
|
coordinator = GaragesAmsterdamDataUpdateCoordinator(hass, entry, client)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -15,8 +15,10 @@ from homeassistant.components.binary_sensor import (
|
|||||||
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 GaragesAmsterdamConfigEntry
|
from .coordinator import (
|
||||||
from .coordinator import GaragesAmsterdamDataUpdateCoordinator
|
GaragesAmsterdamConfigEntry,
|
||||||
|
GaragesAmsterdamDataUpdateCoordinator,
|
||||||
|
)
|
||||||
from .entity import GaragesAmsterdamEntity
|
from .entity import GaragesAmsterdamEntity
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,24 +4,31 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from odp_amsterdam import Garage, ODPAmsterdam, VehicleType
|
from odp_amsterdam import Garage, ODPAmsterdam, VehicleType
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER, SCAN_INTERVAL
|
from .const import DOMAIN, LOGGER, SCAN_INTERVAL
|
||||||
|
|
||||||
|
type GaragesAmsterdamConfigEntry = ConfigEntry[GaragesAmsterdamDataUpdateCoordinator]
|
||||||
|
|
||||||
|
|
||||||
class GaragesAmsterdamDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Garage]]):
|
class GaragesAmsterdamDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Garage]]):
|
||||||
"""Class to manage fetching Garages Amsterdam data from single endpoint."""
|
"""Class to manage fetching Garages Amsterdam data from single endpoint."""
|
||||||
|
|
||||||
|
config_entry: GaragesAmsterdamConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: GaragesAmsterdamConfigEntry,
|
||||||
client: ODPAmsterdam,
|
client: ODPAmsterdam,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize global Garages Amsterdam data updater."""
|
"""Initialize global Garages Amsterdam data updater."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
LOGGER,
|
LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=SCAN_INTERVAL,
|
update_interval=SCAN_INTERVAL,
|
||||||
)
|
)
|
||||||
|
@ -16,8 +16,10 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import GaragesAmsterdamConfigEntry
|
from .coordinator import (
|
||||||
from .coordinator import GaragesAmsterdamDataUpdateCoordinator
|
GaragesAmsterdamConfigEntry,
|
||||||
|
GaragesAmsterdamDataUpdateCoordinator,
|
||||||
|
)
|
||||||
from .entity import GaragesAmsterdamEntity
|
from .entity import GaragesAmsterdamEntity
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user