mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Pass config_entry explicitly to coordinator in tedee (#129432)
* pass entry * pass entry * Update coordinator.py * move type definition
This commit is contained in:
parent
4e7397dc9d
commit
fbe8b6c34d
@ -23,7 +23,7 @@ from homeassistant.helpers import device_registry as dr
|
|||||||
from homeassistant.helpers.network import get_url
|
from homeassistant.helpers.network import get_url
|
||||||
|
|
||||||
from .const import DOMAIN, NAME
|
from .const import DOMAIN, NAME
|
||||||
from .coordinator import TedeeApiCoordinator
|
from .coordinator import TedeeApiCoordinator, TedeeConfigEntry
|
||||||
|
|
||||||
PLATFORMS = [
|
PLATFORMS = [
|
||||||
Platform.BINARY_SENSOR,
|
Platform.BINARY_SENSOR,
|
||||||
@ -33,13 +33,11 @@ PLATFORMS = [
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
type TedeeConfigEntry = ConfigEntry[TedeeApiCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: TedeeConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: TedeeConfigEntry) -> bool:
|
||||||
"""Integration setup."""
|
"""Integration setup."""
|
||||||
|
|
||||||
coordinator = TedeeApiCoordinator(hass)
|
coordinator = TedeeApiCoordinator(hass, entry)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.const import EntityCategory
|
|||||||
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 TedeeConfigEntry
|
from .coordinator import TedeeConfigEntry
|
||||||
from .entity import TedeeDescriptionEntity
|
from .entity import TedeeDescriptionEntity
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""Coordinator for Tedee locks."""
|
"""Coordinator for Tedee locks."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
@ -31,6 +33,8 @@ GET_LOCKS_INTERVAL_SECONDS = 3600
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
type TedeeConfigEntry = ConfigEntry[TedeeApiCoordinator]
|
||||||
|
|
||||||
|
|
||||||
class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]):
|
class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]):
|
||||||
"""Class to handle fetching data from the tedee API centrally."""
|
"""Class to handle fetching data from the tedee API centrally."""
|
||||||
@ -38,11 +42,12 @@ class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]):
|
|||||||
config_entry: ConfigEntry
|
config_entry: ConfigEntry
|
||||||
bridge: TedeeBridge
|
bridge: TedeeBridge
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant) -> None:
|
def __init__(self, hass: HomeAssistant, entry: TedeeConfigEntry) -> None:
|
||||||
"""Initialize coordinator."""
|
"""Initialize coordinator."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=SCAN_INTERVAL,
|
update_interval=SCAN_INTERVAL,
|
||||||
)
|
)
|
||||||
|
@ -9,9 +9,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import TedeeConfigEntry
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import TedeeApiCoordinator
|
from .coordinator import TedeeApiCoordinator, TedeeConfigEntry
|
||||||
from .entity import TedeeEntity
|
from .entity import TedeeEntity
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.const import PERCENTAGE, EntityCategory, UnitOfTime
|
|||||||
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 TedeeConfigEntry
|
from .coordinator import TedeeConfigEntry
|
||||||
from .entity import TedeeDescriptionEntity
|
from .entity import TedeeDescriptionEntity
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user