fix(coordinator): pass config_entry to DataUpdateCoordinator

Pass config_entry explicitly to super().__init__() in both
WeatherDataUpdateCoordinator and HealthCoordinator instead of relying on the
implicit ContextVar (deprecated, breaks in HA 2026.8 for core and was breaking
async_config_entry_first_refresh outside the setup context).

Also resolve each discovered sensor's display name once in received_data
(the previous comprehension awaited translations() twice per key).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ecowitt_support
SchiZzA 2026-06-21 12:51:25 +02:00
parent 9e8eff16d8
commit 6167a3a536
No known key found for this signature in database
2 changed files with 16 additions and 26 deletions

View File

@ -83,7 +83,7 @@ class WeatherDataUpdateCoordinator(DataUpdateCoordinator):
self.pocasi: PocasiPush = PocasiPush(hass, config)
self.ecowitt_bridge: EcowittBridge = EcowittBridge(hass, config)
super().__init__(hass, _LOGGER, name=DOMAIN)
super().__init__(hass, _LOGGER, config_entry=config, name=DOMAIN)
def _health_coordinator(self) -> HealthCoordinator | None:
"""Return the health coordinator for this config entry."""
@ -260,32 +260,21 @@ class WeatherDataUpdateCoordinator(DataUpdateCoordinator):
remaped_items: dict[str, str] = remap_wslink_items(data) if _wslink else remap_items(data)
if sensors := check_disabled(remaped_items, self.config):
if (
translate_sensors := checked(
[
await translations(
self.hass,
DOMAIN,
f"sensor.{t_key}",
key="name",
category="entity",
)
for t_key in sensors
if await translations(
self.hass,
DOMAIN,
f"sensor.{t_key}",
key="name",
category="entity",
)
is not None
],
list[str],
# Resolve each sensor's display name once (the previous comprehension
# awaited translations() twice per key).
translated_sensors: list[str] = []
for t_key in sensors:
name = await translations(
self.hass,
DOMAIN,
f"sensor.{t_key}",
key="name",
category="entity",
)
) is not None:
human_readable: str = "\n".join(translate_sensors)
else:
human_readable = ""
if name is not None:
translated_sensors.append(name)
human_readable = "\n".join(translated_sensors)
await translated_notification(
self.hass,

View File

@ -144,6 +144,7 @@ class HealthCoordinator(DataUpdateCoordinator):
super().__init__(
hass,
logger=_LOGGER,
config_entry=config,
name=f"{DOMAIN}_health",
update_interval=timedelta(minutes=1),
)