mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Use OptionsFlowWithReload in androidtv_remote (#149133)
This commit is contained in:
parent
11dd2dc374
commit
c1e35cc9cf
@ -68,7 +68,6 @@ async def async_setup_entry(
|
|||||||
entry.async_on_unload(
|
entry.async_on_unload(
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
|
||||||
)
|
)
|
||||||
entry.async_on_unload(entry.add_update_listener(async_update_options))
|
|
||||||
entry.async_on_unload(api.disconnect)
|
entry.async_on_unload(api.disconnect)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -80,13 +79,3 @@ async def async_unload_entry(
|
|||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
_LOGGER.debug("async_unload_entry: %s", entry.data)
|
_LOGGER.debug("async_unload_entry: %s", entry.data)
|
||||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
|
|
||||||
async def async_update_options(
|
|
||||||
hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry
|
|
||||||
) -> None:
|
|
||||||
"""Handle options update."""
|
|
||||||
_LOGGER.debug(
|
|
||||||
"async_update_options: data: %s options: %s", entry.data, entry.options
|
|
||||||
)
|
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
|
||||||
|
@ -19,7 +19,7 @@ from homeassistant.config_entries import (
|
|||||||
SOURCE_RECONFIGURE,
|
SOURCE_RECONFIGURE,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
OptionsFlow,
|
OptionsFlowWithReload,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -116,10 +116,10 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
pin = user_input["pin"]
|
pin = user_input["pin"]
|
||||||
await self.api.async_finish_pairing(pin)
|
await self.api.async_finish_pairing(pin)
|
||||||
if self.source == SOURCE_REAUTH:
|
if self.source == SOURCE_REAUTH:
|
||||||
await self.hass.config_entries.async_reload(
|
return self.async_update_reload_and_abort(
|
||||||
self._get_reauth_entry().entry_id
|
self._get_reauth_entry(), reload_even_if_entry_is_unchanged=True
|
||||||
)
|
)
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=self.name,
|
title=self.name,
|
||||||
data={
|
data={
|
||||||
@ -243,7 +243,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return AndroidTVRemoteOptionsFlowHandler(config_entry)
|
return AndroidTVRemoteOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
|
|
||||||
class AndroidTVRemoteOptionsFlowHandler(OptionsFlow):
|
class AndroidTVRemoteOptionsFlowHandler(OptionsFlowWithReload):
|
||||||
"""Android TV Remote options flow."""
|
"""Android TV Remote options flow."""
|
||||||
|
|
||||||
def __init__(self, config_entry: AndroidTVRemoteConfigEntry) -> None:
|
def __init__(self, config_entry: AndroidTVRemoteConfigEntry) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user