Use OptionsFlowWithReload in webostv (#149054)

This commit is contained in:
G Johansson 2025-07-19 15:16:56 +02:00 committed by GitHub
parent 665991a3c1
commit 31167f5da7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 10 deletions

View File

@ -75,8 +75,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: WebOsTvConfigEntry) -> b
)
)
entry.async_on_unload(entry.add_update_listener(async_update_options))
async def async_on_stop(_event: Event) -> None:
"""Unregister callbacks and disconnect."""
client.clear_state_update_callbacks()
@ -88,11 +86,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: WebOsTvConfigEntry) -> b
return True
async def async_update_options(hass: HomeAssistant, entry: WebOsTvConfigEntry) -> None:
"""Update options."""
await hass.config_entries.async_reload(entry.entry_id)
async def async_unload_entry(hass: HomeAssistant, entry: WebOsTvConfigEntry) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):

View File

@ -9,7 +9,11 @@ from urllib.parse import urlparse
from aiowebostv import WebOsClient, WebOsTvPairError
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow
from homeassistant.config_entries import (
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithReload,
)
from homeassistant.const import CONF_CLIENT_SECRET, CONF_HOST
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv
@ -60,7 +64,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
@staticmethod
@callback
def async_get_options_flow(config_entry: WebOsTvConfigEntry) -> OptionsFlow:
def async_get_options_flow(config_entry: WebOsTvConfigEntry) -> OptionsFlowHandler:
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry)
@ -197,7 +201,7 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
)
class OptionsFlowHandler(OptionsFlow):
class OptionsFlowHandler(OptionsFlowWithReload):
"""Handle options."""
def __init__(self, config_entry: WebOsTvConfigEntry) -> None:

View File

@ -54,6 +54,7 @@ async def test_update_options(hass: HomeAssistant, client) -> None:
new_options = config_entry.options.copy()
new_options[CONF_SOURCES] = ["Input02", "Live TV"]
hass.config_entries.async_update_entry(config_entry, options=new_options)
await hass.config_entries.async_reload(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED