mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Explicitly pass in the config_entry in nice_go coordinator (#138070)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
b7949dba44
commit
ac9444a9ba
@ -4,11 +4,10 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import NiceGOUpdateCoordinator
|
||||
from .coordinator import NiceGOConfigEntry, NiceGOUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
PLATFORMS: list[Platform] = [
|
||||
@ -18,13 +17,11 @@ PLATFORMS: list[Platform] = [
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
type NiceGOConfigEntry = ConfigEntry[NiceGOUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: NiceGOConfigEntry) -> bool:
|
||||
"""Set up Nice G.O. from a config entry."""
|
||||
|
||||
coordinator = NiceGOUpdateCoordinator(hass)
|
||||
coordinator = NiceGOUpdateCoordinator(hass, entry)
|
||||
entry.async_on_unload(
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, coordinator.async_ha_stop)
|
||||
)
|
||||
|
@ -54,19 +54,18 @@ class NiceGODevice:
|
||||
vacation_mode: bool | None
|
||||
|
||||
|
||||
type NiceGOConfigEntry = ConfigEntry[NiceGOUpdateCoordinator]
|
||||
|
||||
|
||||
class NiceGOUpdateCoordinator(DataUpdateCoordinator[dict[str, NiceGODevice]]):
|
||||
"""DataUpdateCoordinator for Nice G.O."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
config_entry: NiceGOConfigEntry
|
||||
organization_id: str
|
||||
|
||||
def __init__(self, hass: HomeAssistant) -> None:
|
||||
def __init__(self, hass: HomeAssistant, config_entry: NiceGOConfigEntry) -> None:
|
||||
"""Initialize DataUpdateCoordinator for Nice G.O."""
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
name="Nice G.O.",
|
||||
)
|
||||
super().__init__(hass, _LOGGER, config_entry=config_entry, name="Nice G.O.")
|
||||
|
||||
self.refresh_token = self.config_entry.data[CONF_REFRESH_TOKEN]
|
||||
self.refresh_token_creation_time = self.config_entry.data[
|
||||
|
@ -14,8 +14,8 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import NiceGOConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .coordinator import NiceGOConfigEntry
|
||||
from .entity import NiceGOEntity
|
||||
|
||||
DEVICE_CLASSES = {
|
||||
|
@ -9,8 +9,8 @@ from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import NiceGOConfigEntry
|
||||
from .const import CONF_REFRESH_TOKEN
|
||||
from .coordinator import NiceGOConfigEntry
|
||||
|
||||
TO_REDACT = {CONF_PASSWORD, CONF_EMAIL, CONF_REFRESH_TOKEN, "title", "unique_id"}
|
||||
|
||||
|
@ -7,7 +7,7 @@ from homeassistant.components.event import EventEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import NiceGOConfigEntry
|
||||
from .coordinator import NiceGOConfigEntry
|
||||
from .entity import NiceGOEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -12,13 +12,13 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import NiceGOConfigEntry
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
KNOWN_UNSUPPORTED_DEVICE_TYPES,
|
||||
SUPPORTED_DEVICE_TYPES,
|
||||
UNSUPPORTED_DEVICE_WARNING,
|
||||
)
|
||||
from .coordinator import NiceGOConfigEntry
|
||||
from .entity import NiceGOEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -14,13 +14,13 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import NiceGOConfigEntry
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
KNOWN_UNSUPPORTED_DEVICE_TYPES,
|
||||
SUPPORTED_DEVICE_TYPES,
|
||||
UNSUPPORTED_DEVICE_WARNING,
|
||||
)
|
||||
from .coordinator import NiceGOConfigEntry
|
||||
from .entity import NiceGOEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user