Explicitly pass in the config_entry in myuplink coordinator (#138078)
explicitly pass in the config_entry in coordinatorpull/137224/head
parent
18ea407276
commit
3792888e9d
|
@ -9,7 +9,6 @@ from aiohttp import ClientError, ClientResponseError
|
|||
import jwt
|
||||
from myuplink import MyUplinkAPI, get_manufacturer, get_model, get_system_name
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
|
@ -22,7 +21,7 @@ from homeassistant.helpers.device_registry import DeviceEntry
|
|||
|
||||
from .api import AsyncConfigEntryAuth
|
||||
from .const import DOMAIN, OAUTH2_SCOPES
|
||||
from .coordinator import MyUplinkDataCoordinator
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -35,8 +34,6 @@ PLATFORMS: list[Platform] = [
|
|||
Platform.UPDATE,
|
||||
]
|
||||
|
||||
type MyUplinkConfigEntry = ConfigEntry[MyUplinkDataCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, config_entry: MyUplinkConfigEntry
|
||||
|
@ -77,7 +74,7 @@ async def async_setup_entry(
|
|||
|
||||
# Setup MyUplinkAPI and coordinator for data fetch
|
||||
api = MyUplinkAPI(auth)
|
||||
coordinator = MyUplinkDataCoordinator(hass, api)
|
||||
coordinator = MyUplinkDataCoordinator(hass, config_entry, api)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
config_entry.runtime_data = coordinator
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ from homeassistant.const import Platform
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .const import F_SERIES
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .entity import MyUplinkEntity, MyUplinkSystemEntity
|
||||
from .helpers import find_matching_platform, transform_model_series
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import logging
|
|||
|
||||
from myuplink import Device, DevicePoint, MyUplinkAPI, System
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
|
@ -23,14 +24,22 @@ class CoordinatorData:
|
|||
time: datetime
|
||||
|
||||
|
||||
type MyUplinkConfigEntry = ConfigEntry[MyUplinkDataCoordinator]
|
||||
|
||||
|
||||
class MyUplinkDataCoordinator(DataUpdateCoordinator[CoordinatorData]):
|
||||
"""Coordinator for myUplink data."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, api: MyUplinkAPI) -> None:
|
||||
config_entry: MyUplinkConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, config_entry: MyUplinkConfigEntry, api: MyUplinkAPI
|
||||
) -> None:
|
||||
"""Initialize myUplink coordinator."""
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name="myuplink",
|
||||
update_interval=timedelta(seconds=60),
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ from typing import Any
|
|||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import MyUplinkConfigEntry
|
||||
from .coordinator import MyUplinkConfigEntry
|
||||
|
||||
TO_REDACT = {"access_token", "refresh_token", "serialNumber"}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .const import DOMAIN, F_SERIES
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .entity import MyUplinkEntity
|
||||
from .helpers import find_matching_platform, skip_entity, transform_model_series
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .const import DOMAIN
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .entity import MyUplinkEntity
|
||||
from .helpers import find_matching_platform, skip_entity
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .const import F_SERIES
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .entity import MyUplinkEntity
|
||||
from .helpers import find_matching_platform, skip_entity, transform_model_series
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .const import DOMAIN, F_SERIES
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .entity import MyUplinkEntity
|
||||
from .helpers import find_matching_platform, skip_entity, transform_model_series
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.components.update import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .coordinator import MyUplinkConfigEntry, MyUplinkDataCoordinator
|
||||
from .entity import MyUplinkEntity
|
||||
|
||||
UPDATE_DESCRIPTION = UpdateEntityDescription(
|
||||
|
|
Loading…
Reference in New Issue