mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Explicitly pass in the config_entry in wallbox coordinator (#137874)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
50c15f3056
commit
17569d8186
@ -9,7 +9,7 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
|
|
||||||
from .const import CONF_STATION, DOMAIN, UPDATE_INTERVAL
|
from .const import DOMAIN, UPDATE_INTERVAL
|
||||||
from .coordinator import InvalidAuth, WallboxCoordinator, async_validate_input
|
from .coordinator import InvalidAuth, WallboxCoordinator, async_validate_input
|
||||||
|
|
||||||
PLATFORMS = [Platform.LOCK, Platform.NUMBER, Platform.SENSOR, Platform.SWITCH]
|
PLATFORMS = [Platform.LOCK, Platform.NUMBER, Platform.SENSOR, Platform.SWITCH]
|
||||||
@ -27,11 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
except InvalidAuth as ex:
|
except InvalidAuth as ex:
|
||||||
raise ConfigEntryAuthFailed from ex
|
raise ConfigEntryAuthFailed from ex
|
||||||
|
|
||||||
wallbox_coordinator = WallboxCoordinator(
|
wallbox_coordinator = WallboxCoordinator(hass, entry, wallbox)
|
||||||
entry.data[CONF_STATION],
|
|
||||||
wallbox,
|
|
||||||
hass,
|
|
||||||
)
|
|
||||||
await wallbox_coordinator.async_config_entry_first_refresh()
|
await wallbox_coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = wallbox_coordinator
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = wallbox_coordinator
|
||||||
|
@ -11,6 +11,7 @@ from typing import Any, Concatenate
|
|||||||
import requests
|
import requests
|
||||||
from wallbox import Wallbox
|
from wallbox import Wallbox
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, HomeAssistantError
|
from homeassistant.exceptions import ConfigEntryAuthFailed, HomeAssistantError
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
@ -28,6 +29,7 @@ from .const import (
|
|||||||
CHARGER_STATUS_DESCRIPTION_KEY,
|
CHARGER_STATUS_DESCRIPTION_KEY,
|
||||||
CHARGER_STATUS_ID_KEY,
|
CHARGER_STATUS_ID_KEY,
|
||||||
CODE_KEY,
|
CODE_KEY,
|
||||||
|
CONF_STATION,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
UPDATE_INTERVAL,
|
UPDATE_INTERVAL,
|
||||||
ChargerStatus,
|
ChargerStatus,
|
||||||
@ -107,14 +109,19 @@ async def async_validate_input(hass: HomeAssistant, wallbox: Wallbox) -> None:
|
|||||||
class WallboxCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class WallboxCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Wallbox Coordinator class."""
|
"""Wallbox Coordinator class."""
|
||||||
|
|
||||||
def __init__(self, station: str, wallbox: Wallbox, hass: HomeAssistant) -> None:
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, hass: HomeAssistant, config_entry: ConfigEntry, wallbox: Wallbox
|
||||||
|
) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._station = station
|
self._station = config_entry.data[CONF_STATION]
|
||||||
self._wallbox = wallbox
|
self._wallbox = wallbox
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
update_interval=timedelta(seconds=UPDATE_INTERVAL),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user