From bb21c8785259d88fd6fa21939948f61c6c6cdeb3 Mon Sep 17 00:00:00 2001
From: epenet <6771947+epenet@users.noreply.github.com>
Date: Wed, 2 Oct 2024 16:03:31 +0200
Subject: [PATCH] Use _get_reauth_entry in aseko_pool_live (#127319)

---
 .../components/aseko_pool_live/config_flow.py    | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/homeassistant/components/aseko_pool_live/config_flow.py b/homeassistant/components/aseko_pool_live/config_flow.py
index c0edee694be..f4e61c6a69c 100644
--- a/homeassistant/components/aseko_pool_live/config_flow.py
+++ b/homeassistant/components/aseko_pool_live/config_flow.py
@@ -9,7 +9,12 @@ from typing import Any
 from aioaseko import Aseko, AsekoAPIError, AsekoInvalidCredentials
 import voluptuous as vol
 
-from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
+from homeassistant.config_entries import (
+    SOURCE_REAUTH,
+    ConfigEntry,
+    ConfigFlow,
+    ConfigFlowResult,
+)
 from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_UNIQUE_ID
 
 from .const import DOMAIN
@@ -29,7 +34,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
         }
     )
 
-    reauth_entry: ConfigEntry | None = None
+    reauth_entry: ConfigEntry
 
     async def get_account_info(self, email: str, password: str) -> dict:
         """Get account info from the mobile API and the web API."""
@@ -46,7 +51,6 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
     ) -> ConfigFlowResult:
         """Handle the initial step."""
 
-        self.reauth_entry = None
         errors = {}
 
         if user_input is not None:
@@ -73,7 +77,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
     async def async_store_credentials(self, info: dict[str, Any]) -> ConfigFlowResult:
         """Store validated credentials."""
 
-        if self.reauth_entry:
+        if self.source == SOURCE_REAUTH:
             self.hass.config_entries.async_update_entry(
                 self.reauth_entry,
                 title=info[CONF_EMAIL],
@@ -101,9 +105,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
     ) -> ConfigFlowResult:
         """Perform reauth upon an API authentication error."""
 
-        self.reauth_entry = self.hass.config_entries.async_get_entry(
-            self.context["entry_id"]
-        )
+        self.reauth_entry = self._get_reauth_entry()
 
         return await self.async_step_reauth_confirm()
 
-- 
GitLab