Explicitly pass in the config_entry in idasen_desk coordinator (#138146)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 21:04:46 +01:00 committed by GitHub
parent 0decb0cfba
commit b65403f332
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 15 additions and 11 deletions

View File

@ -9,25 +9,22 @@ from idasen_ha.errors import AuthFailedError
from homeassistant.components import bluetooth
from homeassistant.components.bluetooth.match import ADDRESS, BluetoothCallbackMatcher
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, EVENT_HOMEASSISTANT_STOP, Platform
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
from .coordinator import IdasenDeskCoordinator
from .coordinator import IdasenDeskConfigEntry, IdasenDeskCoordinator
PLATFORMS: list[Platform] = [Platform.BUTTON, Platform.COVER, Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)
type IdasenDeskConfigEntry = ConfigEntry[IdasenDeskCoordinator]
async def async_setup_entry(hass: HomeAssistant, entry: IdasenDeskConfigEntry) -> bool:
"""Set up IKEA Idasen from a config entry."""
address: str = entry.data[CONF_ADDRESS].upper()
coordinator = IdasenDeskCoordinator(hass, entry.title, address)
coordinator = IdasenDeskCoordinator(hass, entry, address)
entry.runtime_data = coordinator
try:

View File

@ -10,7 +10,7 @@ from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import IdasenDeskConfigEntry, IdasenDeskCoordinator
from .coordinator import IdasenDeskConfigEntry, IdasenDeskCoordinator
from .entity import IdasenDeskEntity
_LOGGER = logging.getLogger(__name__)

View File

@ -7,24 +7,31 @@ import logging
from idasen_ha import Desk
from homeassistant.components import bluetooth
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
type IdasenDeskConfigEntry = ConfigEntry[IdasenDeskCoordinator]
class IdasenDeskCoordinator(DataUpdateCoordinator[int | None]):
"""Class to manage updates for the Idasen Desk."""
config_entry: IdasenDeskConfigEntry
def __init__(
self,
hass: HomeAssistant,
name: str,
config_entry: IdasenDeskConfigEntry,
address: str,
) -> None:
"""Init IdasenDeskCoordinator."""
super().__init__(hass, _LOGGER, name=name)
super().__init__(
hass, _LOGGER, config_entry=config_entry, name=config_entry.title
)
self.address = address
self._expected_connected = False

View File

@ -16,7 +16,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import IdasenDeskConfigEntry, IdasenDeskCoordinator
from .coordinator import IdasenDeskConfigEntry, IdasenDeskCoordinator
from .entity import IdasenDeskEntity

View File

@ -5,7 +5,7 @@ from __future__ import annotations
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import IdasenDeskCoordinator
from .coordinator import IdasenDeskCoordinator
class IdasenDeskEntity(CoordinatorEntity[IdasenDeskCoordinator]):

View File

@ -15,7 +15,7 @@ from homeassistant.const import UnitOfLength
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import IdasenDeskConfigEntry, IdasenDeskCoordinator
from .coordinator import IdasenDeskConfigEntry, IdasenDeskCoordinator
from .entity import IdasenDeskEntity