mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Set config_entry explicitly in history stats coordinator (#129417)
Set config_entry explicitely in history stats coordinator
This commit is contained in:
parent
5dc0bedbc4
commit
5d3af27928
@ -41,7 +41,7 @@ async def async_setup_entry(
|
||||
Template(end, hass) if end else None,
|
||||
duration,
|
||||
)
|
||||
coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, entry.title)
|
||||
coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, entry, entry.title)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
entry.runtime_data = coordinator
|
||||
|
||||
|
@ -6,6 +6,7 @@ from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import (
|
||||
CALLBACK_TYPE,
|
||||
Event,
|
||||
@ -33,6 +34,7 @@ class HistoryStatsUpdateCoordinator(DataUpdateCoordinator[HistoryStatsState]):
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
history_stats: HistoryStats,
|
||||
config_entry: ConfigEntry | None,
|
||||
name: str,
|
||||
) -> None:
|
||||
"""Initialize DataUpdateCoordinator."""
|
||||
@ -43,6 +45,7 @@ class HistoryStatsUpdateCoordinator(DataUpdateCoordinator[HistoryStatsState]):
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=name,
|
||||
update_interval=UPDATE_INTERVAL,
|
||||
)
|
||||
|
@ -104,7 +104,7 @@ async def async_setup_platform(
|
||||
unique_id: str | None = config.get(CONF_UNIQUE_ID)
|
||||
|
||||
history_stats = HistoryStats(hass, entity_id, entity_states, start, end, duration)
|
||||
coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, name)
|
||||
coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, None, name)
|
||||
await coordinator.async_refresh()
|
||||
if not coordinator.last_update_success:
|
||||
raise PlatformNotReady from coordinator.last_exception
|
||||
|
Loading…
x
Reference in New Issue
Block a user