mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Explicitly pass in the config_entry in lifx coordinator (#138110)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
faf4ad07fc
commit
56eecf05e7
@ -211,7 +211,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
except socket.gaierror as ex:
|
except socket.gaierror as ex:
|
||||||
connection.async_stop()
|
connection.async_stop()
|
||||||
raise ConfigEntryNotReady(f"Could not resolve {host}: {ex}") from ex
|
raise ConfigEntryNotReady(f"Could not resolve {host}: {ex}") from ex
|
||||||
coordinator = LIFXUpdateCoordinator(hass, connection, entry.title)
|
coordinator = LIFXUpdateCoordinator(hass, entry, connection)
|
||||||
coordinator.async_setup()
|
coordinator.async_setup()
|
||||||
try:
|
try:
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
@ -23,6 +23,7 @@ from aiolifx_themes.themes import ThemeLibrary, ThemePainter
|
|||||||
from awesomeversion import AwesomeVersion
|
from awesomeversion import AwesomeVersion
|
||||||
from propcache.api import cached_property
|
from propcache.api import cached_property
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
SIGNAL_STRENGTH_DECIBELS,
|
SIGNAL_STRENGTH_DECIBELS,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
@ -86,11 +87,13 @@ class SkyType(IntEnum):
|
|||||||
class LIFXUpdateCoordinator(DataUpdateCoordinator[None]):
|
class LIFXUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||||
"""DataUpdateCoordinator to gather data for a specific lifx device."""
|
"""DataUpdateCoordinator to gather data for a specific lifx device."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
connection: LIFXConnection,
|
connection: LIFXConnection,
|
||||||
title: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize DataUpdateCoordinator."""
|
"""Initialize DataUpdateCoordinator."""
|
||||||
assert connection.device is not None
|
assert connection.device is not None
|
||||||
@ -105,7 +108,8 @@ class LIFXUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_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),
|
update_interval=timedelta(seconds=LIGHT_UPDATE_INTERVAL),
|
||||||
# We don't want an immediate refresh since the device
|
# We don't want an immediate refresh since the device
|
||||||
# takes a moment to reflect the state change
|
# takes a moment to reflect the state change
|
||||||
|
Loading…
x
Reference in New Issue
Block a user