fix reload

This commit is contained in:
Julian Pawlowski 2025-11-02 23:53:16 +00:00
parent 54d0359be8
commit 3b87cc67e5
3 changed files with 3 additions and 5 deletions

View file

@ -67,10 +67,11 @@ async def async_setup_entry(
# https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities # https://developers.home-assistant.io/docs/integration_fetching_data#coordinated-single-api-poll-for-data-for-all-entities
if entry.state == ConfigEntryState.SETUP_IN_PROGRESS: if entry.state == ConfigEntryState.SETUP_IN_PROGRESS:
await coordinator.async_config_entry_first_refresh() await coordinator.async_config_entry_first_refresh()
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
else: else:
await coordinator.async_refresh() await coordinator.async_refresh()
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True return True

View file

@ -134,7 +134,7 @@ class TibberPricesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
async def async_shutdown(self) -> None: async def async_shutdown(self) -> None:
"""Shut down the coordinator and clean up timers.""" """Shut down the coordinator and clean up timers."""
if self._quarter_hour_timer_handle: if self._quarter_hour_timer_handle:
self._quarter_hour_timer_handle() self._quarter_hour_timer_handle.cancel()
self._quarter_hour_timer_handle = None self._quarter_hour_timer_handle = None
def _has_existing_main_coordinator(self) -> bool: def _has_existing_main_coordinator(self) -> bool:

View file

@ -5,9 +5,6 @@ from __future__ import annotations
from datetime import date, datetime, timedelta from datetime import date, datetime, timedelta
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Callable
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
SensorDeviceClass, SensorDeviceClass,
SensorEntity, SensorEntity,