Skip to content
Snippets Groups Projects
Unverified Commit bb21c878 authored by epenet's avatar epenet Committed by GitHub
Browse files

Use _get_reauth_entry in aseko_pool_live (#127319)

parent f0df25f8
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,12 @@ from typing import Any ...@@ -9,7 +9,12 @@ from typing import Any
from aioaseko import Aseko, AsekoAPIError, AsekoInvalidCredentials from aioaseko import Aseko, AsekoAPIError, AsekoInvalidCredentials
import voluptuous as vol 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 homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_UNIQUE_ID
from .const import DOMAIN from .const import DOMAIN
...@@ -29,7 +34,7 @@ class AsekoConfigFlow(ConfigFlow, domain=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: async def get_account_info(self, email: str, password: str) -> dict:
"""Get account info from the mobile API and the web API.""" """Get account info from the mobile API and the web API."""
...@@ -46,7 +51,6 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN): ...@@ -46,7 +51,6 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle the initial step.""" """Handle the initial step."""
self.reauth_entry = None
errors = {} errors = {}
if user_input is not None: if user_input is not None:
...@@ -73,7 +77,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN): ...@@ -73,7 +77,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_store_credentials(self, info: dict[str, Any]) -> ConfigFlowResult: async def async_store_credentials(self, info: dict[str, Any]) -> ConfigFlowResult:
"""Store validated credentials.""" """Store validated credentials."""
if self.reauth_entry: if self.source == SOURCE_REAUTH:
self.hass.config_entries.async_update_entry( self.hass.config_entries.async_update_entry(
self.reauth_entry, self.reauth_entry,
title=info[CONF_EMAIL], title=info[CONF_EMAIL],
...@@ -101,9 +105,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN): ...@@ -101,9 +105,7 @@ class AsekoConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error.""" """Perform reauth upon an API authentication error."""
self.reauth_entry = self.hass.config_entries.async_get_entry( self.reauth_entry = self._get_reauth_entry()
self.context["entry_id"]
)
return await self.async_step_reauth_confirm() return await self.async_step_reauth_confirm()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment