Explicitly pass in the config_entry in lifx coordinator (#138110)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 20:17:48 +01:00 committed by GitHub
parent faf4ad07fc
commit 56eecf05e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -211,7 +211,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except socket.gaierror as ex:
connection.async_stop()
raise ConfigEntryNotReady(f"Could not resolve {host}: {ex}") from ex
coordinator = LIFXUpdateCoordinator(hass, connection, entry.title)
coordinator = LIFXUpdateCoordinator(hass, entry, connection)
coordinator.async_setup()
try:
await coordinator.async_config_entry_first_refresh()

View File

@ -23,6 +23,7 @@ from aiolifx_themes.themes import ThemeLibrary, ThemePainter
from awesomeversion import AwesomeVersion
from propcache.api import cached_property
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
SIGNAL_STRENGTH_DECIBELS,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
@ -86,11 +87,13 @@ class SkyType(IntEnum):
class LIFXUpdateCoordinator(DataUpdateCoordinator[None]):
"""DataUpdateCoordinator to gather data for a specific lifx device."""
config_entry: ConfigEntry
def __init__(
self,
hass: HomeAssistant,
config_entry: ConfigEntry,
connection: LIFXConnection,
title: str,
) -> None:
"""Initialize DataUpdateCoordinator."""
assert connection.device is not None
@ -105,7 +108,8 @@ class LIFXUpdateCoordinator(DataUpdateCoordinator[None]):
super().__init__(
hass,
_LOGGER,
name=f"{title} ({self.device.ip_addr})",
config_entry=config_entry,
name=f"{config_entry.title} ({self.device.ip_addr})",
update_interval=timedelta(seconds=LIGHT_UPDATE_INTERVAL),
# We don't want an immediate refresh since the device
# takes a moment to reflect the state change