mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +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,
|
Template(end, hass) if end else None,
|
||||||
duration,
|
duration,
|
||||||
)
|
)
|
||||||
coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, entry.title)
|
coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, entry, entry.title)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ from datetime import timedelta
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
CALLBACK_TYPE,
|
CALLBACK_TYPE,
|
||||||
Event,
|
Event,
|
||||||
@ -33,6 +34,7 @@ class HistoryStatsUpdateCoordinator(DataUpdateCoordinator[HistoryStatsState]):
|
|||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
history_stats: HistoryStats,
|
history_stats: HistoryStats,
|
||||||
|
config_entry: ConfigEntry | None,
|
||||||
name: str,
|
name: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize DataUpdateCoordinator."""
|
"""Initialize DataUpdateCoordinator."""
|
||||||
@ -43,6 +45,7 @@ class HistoryStatsUpdateCoordinator(DataUpdateCoordinator[HistoryStatsState]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=name,
|
name=name,
|
||||||
update_interval=UPDATE_INTERVAL,
|
update_interval=UPDATE_INTERVAL,
|
||||||
)
|
)
|
||||||
|
@ -104,7 +104,7 @@ async def async_setup_platform(
|
|||||||
unique_id: str | None = config.get(CONF_UNIQUE_ID)
|
unique_id: str | None = config.get(CONF_UNIQUE_ID)
|
||||||
|
|
||||||
history_stats = HistoryStats(hass, entity_id, entity_states, start, end, duration)
|
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()
|
await coordinator.async_refresh()
|
||||||
if not coordinator.last_update_success:
|
if not coordinator.last_update_success:
|
||||||
raise PlatformNotReady from coordinator.last_exception
|
raise PlatformNotReady from coordinator.last_exception
|
||||||
|
Loading…
x
Reference in New Issue
Block a user