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