Use OptionsFlowWithReload in onkyo (#149093)

This commit is contained in:
G Johansson 2025-07-20 23:17:43 +02:00 committed by GitHub
parent b8d45fba24
commit e3577de9d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 29 deletions

View File

@ -47,7 +47,6 @@ async def async_setup(hass: HomeAssistant, _: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> bool:
"""Set up the Onkyo config entry."""
entry.async_on_unload(entry.add_update_listener(update_listener))
host = entry.data[CONF_HOST]
@ -82,8 +81,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: OnkyoConfigEntry) -> bo
receiver.conn.close()
return unload_ok
async def update_listener(hass: HomeAssistant, entry: OnkyoConfigEntry) -> None:
"""Handle options update."""
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
from homeassistant.core import callback
@ -329,7 +329,7 @@ class OnkyoConfigFlow(ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlow:
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlowWithReload:
"""Return the options flow."""
return OnkyoOptionsFlowHandler()
@ -357,7 +357,7 @@ OPTIONS_STEP_INIT_SCHEMA = vol.Schema(
)
class OnkyoOptionsFlowHandler(OptionsFlow):
class OnkyoOptionsFlowHandler(OptionsFlowWithReload):
"""Handle an options flow for Onkyo."""
_data: dict[str, Any]

View File

@ -33,26 +33,6 @@ async def test_load_unload_entry(
assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_update_entry(
hass: HomeAssistant,
config_entry: MockConfigEntry,
) -> None:
"""Test update options."""
with patch.object(hass.config_entries, "async_reload", return_value=True):
config_entry = create_empty_config_entry()
receiver_info = create_receiver_info(1)
await setup_integration(hass, config_entry, receiver_info)
# Force option change
assert hass.config_entries.async_update_entry(
config_entry, options={"option": "new_value"}
)
await hass.async_block_till_done()
hass.config_entries.async_reload.assert_called_with(config_entry.entry_id)
async def test_no_connection(
hass: HomeAssistant,
config_entry: MockConfigEntry,