From 87c9c0c3b11fbcb1467e46b99ed286b9b8db0098 Mon Sep 17 00:00:00 2001
From: epenet <6771947+epenet@users.noreply.github.com>
Date: Sun, 20 Oct 2024 09:55:16 +0200
Subject: [PATCH] Use new reauth helpers in whirlpool (#128825)

---
 homeassistant/components/whirlpool/config_flow.py | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/homeassistant/components/whirlpool/config_flow.py b/homeassistant/components/whirlpool/config_flow.py
index 7c39b1fbb29..069a5ca1e4f 100644
--- a/homeassistant/components/whirlpool/config_flow.py
+++ b/homeassistant/components/whirlpool/config_flow.py
@@ -12,7 +12,7 @@ from whirlpool.appliancesmanager import AppliancesManager
 from whirlpool.auth import Auth
 from whirlpool.backendselector import BackendSelector
 
-from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
+from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
 from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
 from homeassistant.core import HomeAssistant
 from homeassistant.exceptions import HomeAssistantError
@@ -71,14 +71,11 @@ class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
     """Handle a config flow for Whirlpool Sixth Sense."""
 
     VERSION = 1
-    entry: ConfigEntry | None
 
     async def async_step_reauth(
         self, entry_data: Mapping[str, Any]
     ) -> ConfigFlowResult:
         """Handle re-authentication with Whirlpool Sixth Sense."""
-
-        self.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(
@@ -88,10 +85,10 @@ class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
         errors: dict[str, str] = {}
 
         if user_input:
-            assert self.entry is not None
+            reauth_entry = self._get_reauth_entry()
             password = user_input[CONF_PASSWORD]
             brand = user_input[CONF_BRAND]
-            data = {**self.entry.data, CONF_PASSWORD: password, CONF_BRAND: brand}
+            data = {**reauth_entry.data, CONF_PASSWORD: password, CONF_BRAND: brand}
 
             try:
                 await validate_input(self.hass, data)
@@ -100,9 +97,7 @@ class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
             except (CannotConnect, TimeoutError):
                 errors["base"] = "cannot_connect"
             else:
-                self.hass.config_entries.async_update_entry(self.entry, data=data)
-                await self.hass.config_entries.async_reload(self.entry.entry_id)
-                return self.async_abort(reason="reauth_successful")
+                return self.async_update_reload_and_abort(reauth_entry, data=data)
 
         return self.async_show_form(
             step_id="reauth_confirm",
-- 
GitLab