diff --git a/homeassistant/components/roborock/config_flow.py b/homeassistant/components/roborock/config_flow.py index c6dee7ce4ed..06fbf3e717e 100644 --- a/homeassistant/components/roborock/config_flow.py +++ b/homeassistant/components/roborock/config_flow.py @@ -19,6 +19,7 @@ from roborock.web_api import RoborockApiClient import voluptuous as vol from homeassistant.config_entries import ( + SOURCE_REAUTH, ConfigEntry, ConfigFlow, ConfigFlowResult, @@ -44,7 +45,6 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a config flow for Roborock.""" VERSION = 1 - reauth_entry: ConfigEntry | None = None def __init__(self) -> None: """Initialize the config flow.""" @@ -116,11 +116,12 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN): _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" 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.reauth_entry, + reauth_entry, data={ - **self.reauth_entry.data, + **reauth_entry.data, CONF_USER_DATA: login_data.as_dict(), }, ) @@ -140,9 +141,6 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN): self._username = entry_data[CONF_USERNAME] assert 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() async def async_step_reauth_confirm(