fix: dynamic reload

This commit is contained in:
Björn Stormwall
2026-06-06 19:00:49 +02:00
parent 108d154b3d
commit 6cd2b406d8
@@ -16,13 +16,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
# Full reload on options change so coordinator and entity state are rebuilt cleanly.
entry.async_on_unload(entry.add_update_listener(_async_options_updated))
return True
async def _async_options_updated(hass: HomeAssistant, entry: ConfigEntry) -> None:
coordinator: EaseeSolarCoordinator = hass.data[DOMAIN][entry.entry_id]
await coordinator.async_request_refresh()
await hass.config_entries.async_reload(entry.entry_id)
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Called by HA when the user presses Reload in the UI."""
await async_unload_entry(hass, entry)
await async_setup_entry(hass, entry)
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: