Use OptionsFlowWithReload in reolink (#149132)

This commit is contained in:
G Johansson 2025-07-20 23:44:39 +02:00 committed by GitHub
parent 61ca0b6b86
commit 77a954df9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 33 deletions

View File

@ -243,10 +243,6 @@ async def async_setup_entry(
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS) 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 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( async def async_unload_entry(
hass: HomeAssistant, config_entry: ReolinkConfigEntry hass: HomeAssistant, config_entry: ReolinkConfigEntry
) -> bool: ) -> bool:

View File

@ -23,7 +23,7 @@ from homeassistant.config_entries import (
SOURCE_RECONFIGURE, SOURCE_RECONFIGURE,
ConfigFlow, ConfigFlow,
ConfigFlowResult, ConfigFlowResult,
OptionsFlow, OptionsFlowWithReload,
) )
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@ -61,7 +61,7 @@ DEFAULT_OPTIONS = {CONF_PROTOCOL: DEFAULT_PROTOCOL}
API_STARTUP_TIME = 5 API_STARTUP_TIME = 5
class ReolinkOptionsFlowHandler(OptionsFlow): class ReolinkOptionsFlowHandler(OptionsFlowWithReload):
"""Handle Reolink options.""" """Handle Reolink options."""
async def async_step_init( async def async_step_init(

View File

@ -180,26 +180,6 @@ async def test_credential_error_three(
assert (HOMEASSISTANT_DOMAIN, issue_id) in issue_registry.issues 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( @pytest.mark.parametrize(
("attr", "value", "expected_models"), ("attr", "value", "expected_models"),
[ [