mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Use OptionsFlowWithReload in reolink (#149132)
This commit is contained in:
parent
61ca0b6b86
commit
77a954df9b
@ -243,10 +243,6 @@ async def async_setup_entry(
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
|
||||
|
||||
config_entry.async_on_unload(
|
||||
config_entry.add_update_listener(entry_update_listener)
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@ -295,13 +291,6 @@ async def register_callbacks(
|
||||
)
|
||||
|
||||
|
||||
async def entry_update_listener(
|
||||
hass: HomeAssistant, config_entry: ReolinkConfigEntry
|
||||
) -> None:
|
||||
"""Update the configuration of the host entity."""
|
||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||
|
||||
|
||||
async def async_unload_entry(
|
||||
hass: HomeAssistant, config_entry: ReolinkConfigEntry
|
||||
) -> bool:
|
||||
|
@ -23,7 +23,7 @@ from homeassistant.config_entries import (
|
||||
SOURCE_RECONFIGURE,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
OptionsFlowWithReload,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
@ -61,7 +61,7 @@ DEFAULT_OPTIONS = {CONF_PROTOCOL: DEFAULT_PROTOCOL}
|
||||
API_STARTUP_TIME = 5
|
||||
|
||||
|
||||
class ReolinkOptionsFlowHandler(OptionsFlow):
|
||||
class ReolinkOptionsFlowHandler(OptionsFlowWithReload):
|
||||
"""Handle Reolink options."""
|
||||
|
||||
async def async_step_init(
|
||||
|
@ -180,26 +180,6 @@ async def test_credential_error_three(
|
||||
assert (HOMEASSISTANT_DOMAIN, issue_id) in issue_registry.issues
|
||||
|
||||
|
||||
async def test_entry_reloading(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
reolink_host: MagicMock,
|
||||
) -> None:
|
||||
"""Test the entry is reloaded correctly when settings change."""
|
||||
reolink_host.is_nvr = False
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert reolink_host.logout.call_count == 0
|
||||
assert config_entry.title == "test_reolink_name"
|
||||
|
||||
hass.config_entries.async_update_entry(config_entry, title="New Name")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert reolink_host.logout.call_count == 1
|
||||
assert config_entry.title == "New Name"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("attr", "value", "expected_models"),
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user