From 56eecf05e7d22a8676ca865ac73795a3048145c5 Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sun, 9 Feb 2025 20:17:48 +0100 Subject: [PATCH] Explicitly pass in the config_entry in lifx coordinator (#138110) explicitly pass in the config_entry in coordinator --- homeassistant/components/lifx/__init__.py | 2 +- homeassistant/components/lifx/coordinator.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/lifx/__init__.py b/homeassistant/components/lifx/__init__.py index 2847862029f..7a6d95549ff 100644 --- a/homeassistant/components/lifx/__init__.py +++ b/homeassistant/components/lifx/__init__.py @@ -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() diff --git a/homeassistant/components/lifx/coordinator.py b/homeassistant/components/lifx/coordinator.py index eaaff7e6540..b77dbdc015a 100644 --- a/homeassistant/components/lifx/coordinator.py +++ b/homeassistant/components/lifx/coordinator.py @@ -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