mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 01:28:27 +00:00
Use OptionsFlowWithReload in roborock (#149118)
This commit is contained in:
@ -43,8 +43,6 @@ _LOGGER = logging.getLogger(__name__)
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: RoborockConfigEntry) -> bool:
|
||||
"""Set up roborock from a config entry."""
|
||||
|
||||
entry.async_on_unload(entry.add_update_listener(update_listener))
|
||||
|
||||
user_data = UserData.from_dict(entry.data[CONF_USER_DATA])
|
||||
api_client = RoborockApiClient(
|
||||
entry.data[CONF_USERNAME],
|
||||
@ -336,12 +334,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: RoborockConfigEntry) ->
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
|
||||
async def update_listener(hass: HomeAssistant, entry: RoborockConfigEntry) -> None:
|
||||
"""Handle options update."""
|
||||
# Reload entry to update data
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
|
||||
async def async_remove_entry(hass: HomeAssistant, entry: RoborockConfigEntry) -> None:
|
||||
"""Handle removal of an entry."""
|
||||
await async_remove_map_storage(hass, entry.entry_id)
|
||||
|
@ -23,7 +23,7 @@ from homeassistant.config_entries import (
|
||||
SOURCE_REAUTH,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
OptionsFlowWithReload,
|
||||
)
|
||||
from homeassistant.const import CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
@ -124,14 +124,9 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
if self.source == SOURCE_REAUTH:
|
||||
self._abort_if_unique_id_mismatch(reason="wrong_account")
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
self.hass.config_entries.async_update_entry(
|
||||
reauth_entry,
|
||||
data={
|
||||
**reauth_entry.data,
|
||||
CONF_USER_DATA: user_data.as_dict(),
|
||||
},
|
||||
return self.async_update_reload_and_abort(
|
||||
reauth_entry, data_updates={CONF_USER_DATA: user_data.as_dict()}
|
||||
)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
self._abort_if_unique_id_configured(error="already_configured_account")
|
||||
return self._create_entry(self._client, self._username, user_data)
|
||||
|
||||
@ -202,7 +197,7 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
return RoborockOptionsFlowHandler(config_entry)
|
||||
|
||||
|
||||
class RoborockOptionsFlowHandler(OptionsFlow):
|
||||
class RoborockOptionsFlowHandler(OptionsFlowWithReload):
|
||||
"""Handle an option flow for Roborock."""
|
||||
|
||||
def __init__(self, config_entry: RoborockConfigEntry) -> None:
|
||||
|
Reference in New Issue
Block a user