mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 01:28:27 +00:00
Use OptionsFlowWithReload in Workday (#149043)
This commit is contained in:
@ -94,16 +94,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
new_options[CONF_LANGUAGE] = default_language
|
||||
hass.config_entries.async_update_entry(entry, options=new_options)
|
||||
|
||||
entry.async_on_unload(entry.add_update_listener(async_update_listener))
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
return True
|
||||
|
||||
|
||||
async def async_update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Update listener for options."""
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload Workday config entry."""
|
||||
|
||||
|
@ -12,7 +12,7 @@ from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
OptionsFlowWithReload,
|
||||
)
|
||||
from homeassistant.const import CONF_COUNTRY, CONF_LANGUAGE, CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
@ -311,7 +311,7 @@ class WorkdayConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
)
|
||||
|
||||
|
||||
class WorkdayOptionsFlowHandler(OptionsFlow):
|
||||
class WorkdayOptionsFlowHandler(OptionsFlowWithReload):
|
||||
"""Handle Workday options."""
|
||||
|
||||
async def async_step_init(
|
||||
|
@ -45,6 +45,7 @@ async def test_update_options(
|
||||
new_options["add_holidays"] = ["2023-04-12"]
|
||||
|
||||
hass.config_entries.async_update_entry(entry, options=new_options)
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entry_check = hass.config_entries.async_get_entry("1")
|
||||
|
Reference in New Issue
Block a user