Use new reauth helpers in roborock (#128726)

This commit is contained in:
epenet 2024-10-19 11:15:58 +02:00 committed by GitHub
parent 31a58a21c6
commit ed9f40fc4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,6 +19,7 @@ from roborock.web_api import RoborockApiClient
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ( from homeassistant.config_entries import (
SOURCE_REAUTH,
ConfigEntry, ConfigEntry,
ConfigFlow, ConfigFlow,
ConfigFlowResult, ConfigFlowResult,
@ -44,7 +45,6 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Roborock.""" """Handle a config flow for Roborock."""
VERSION = 1 VERSION = 1
reauth_entry: ConfigEntry | None = None
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize the config flow.""" """Initialize the config flow."""
@ -116,11 +116,12 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN):
_LOGGER.exception("Unexpected exception") _LOGGER.exception("Unexpected exception")
errors["base"] = "unknown" errors["base"] = "unknown"
else: else:
if self.reauth_entry is not None: if self.source == SOURCE_REAUTH:
reauth_entry = self._get_reauth_entry()
self.hass.config_entries.async_update_entry( self.hass.config_entries.async_update_entry(
self.reauth_entry, reauth_entry,
data={ data={
**self.reauth_entry.data, **reauth_entry.data,
CONF_USER_DATA: login_data.as_dict(), CONF_USER_DATA: login_data.as_dict(),
}, },
) )
@ -140,9 +141,6 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN):
self._username = entry_data[CONF_USERNAME] self._username = entry_data[CONF_USERNAME]
assert self._username assert self._username
self._client = RoborockApiClient(self._username) self._client = RoborockApiClient(self._username)
self.reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
)
return await self.async_step_reauth_confirm() return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm( async def async_step_reauth_confirm(