mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Use OptionsFlowWithReload in wled (#149046)
This commit is contained in:
parent
8a2493e9d2
commit
665991a3c1
@ -48,9 +48,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: WLEDConfigEntry) -> bool
|
|||||||
# Set up all platforms for this device/entry.
|
# Set up all platforms for this device/entry.
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
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
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -65,8 +62,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: WLEDConfigEntry) -> boo
|
|||||||
coordinator.unsub()
|
coordinator.unsub()
|
||||||
|
|
||||||
return unload_ok
|
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)
|
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.config_entries import (
|
|||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
OptionsFlow,
|
OptionsFlowWithReload,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC
|
from homeassistant.const import CONF_HOST, CONF_MAC
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -120,7 +120,7 @@ class WLEDFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
return await wled.update()
|
return await wled.update()
|
||||||
|
|
||||||
|
|
||||||
class WLEDOptionsFlowHandler(OptionsFlow):
|
class WLEDOptionsFlowHandler(OptionsFlowWithReload):
|
||||||
"""Handle WLED options."""
|
"""Handle WLED options."""
|
||||||
|
|
||||||
async def async_step_init(
|
async def async_step_init(
|
||||||
|
@ -373,6 +373,7 @@ async def test_single_segment_with_keep_main_light(
|
|||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
init_integration, options={CONF_KEEP_MAIN_LIGHT: True}
|
init_integration, options={CONF_KEEP_MAIN_LIGHT: True}
|
||||||
)
|
)
|
||||||
|
await hass.config_entries.async_reload(init_integration.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert (state := hass.states.get("light.wled_rgb_light_main"))
|
assert (state := hass.states.get("light.wled_rgb_light_main"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user