From 9ba58233ec7cbc4fa06d006617d76577db0b7df0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 3 Oct 2024 14:34:42 +0200 Subject: [PATCH] Use reauth helpers in aosmith config flow (#127432) Use async_update_reload_and_abort in aosmith config flow --- .../components/aosmith/config_flow.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/aosmith/config_flow.py b/homeassistant/components/aosmith/config_flow.py index d2b52a788eb..1e618a79f9c 100644 --- a/homeassistant/components/aosmith/config_flow.py +++ b/homeassistant/components/aosmith/config_flow.py @@ -87,20 +87,15 @@ class AOSmithConfigFlow(ConfigFlow, domain=DOMAIN): errors: dict[str, str] = {} if user_input: password = user_input[CONF_PASSWORD] - entry_id = self.context["entry_id"] - if entry := self.hass.config_entries.async_get_entry(entry_id): - error = await self._async_validate_credentials( - self._reauth_email, password + entry = self._get_reauth_entry() + error = await self._async_validate_credentials(self._reauth_email, password) + if error is None: + return self.async_update_reload_and_abort( + entry, + data=entry.data | user_input, ) - if error is None: - self.hass.config_entries.async_update_entry( - entry, - data=entry.data | user_input, - ) - await self.hass.config_entries.async_reload(entry.entry_id) - return self.async_abort(reason="reauth_successful") - errors["base"] = error + errors["base"] = error return self.async_show_form( step_id="reauth_confirm",