Use OptionsFlowWithReload in wled (#149046)

This commit is contained in:
G Johansson
2025-07-19 14:27:46 +02:00
committed by GitHub
parent 8a2493e9d2
commit 665991a3c1
3 changed files with 3 additions and 10 deletions

View File

@ -48,9 +48,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: WLEDConfigEntry) -> bool
# Set up all platforms for this device/entry.
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
# Reload entry when its updated.
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
return True
@ -65,8 +62,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: WLEDConfigEntry) -> boo
coordinator.unsub()
return unload_ok
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload the config entry when it changed."""
await hass.config_entries.async_reload(entry.entry_id)

View File

@ -12,7 +12,7 @@ from homeassistant.config_entries import (
ConfigEntry,
ConfigFlow,
ConfigFlowResult,
OptionsFlow,
OptionsFlowWithReload,
)
from homeassistant.const import CONF_HOST, CONF_MAC
from homeassistant.core import callback
@ -120,7 +120,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
return await wled.update()
class WLEDOptionsFlowHandler(OptionsFlow):
class WLEDOptionsFlowHandler(OptionsFlowWithReload):
"""Handle WLED options."""
async def async_step_init(

View File

@ -373,6 +373,7 @@ async def test_single_segment_with_keep_main_light(
hass.config_entries.async_update_entry(
init_integration, options={CONF_KEEP_MAIN_LIGHT: True}
)
await hass.config_entries.async_reload(init_integration.entry_id)
await hass.async_block_till_done()
assert (state := hass.states.get("light.wled_rgb_light_main"))