mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Use _get_reauth/reconfigure_entry in solarlog (#127310)
This commit is contained in:
parent
74441d2771
commit
5759539e08
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
from urllib.parse import ParseResult, urlparse
|
from urllib.parse import ParseResult, urlparse
|
||||||
|
|
||||||
from solarlog_cli.solarlog_connector import SolarLogConnector
|
from solarlog_cli.solarlog_connector import SolarLogConnector
|
||||||
@ -26,7 +26,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN):
|
class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for solarlog."""
|
"""Handle a config flow for solarlog."""
|
||||||
|
|
||||||
_entry: SolarlogConfigEntry | None = None
|
_entry: SolarlogConfigEntry
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
MINOR_VERSION = 3
|
MINOR_VERSION = 3
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self._entry = self._get_reconfigure_entry()
|
||||||
|
|
||||||
return await self.async_step_reconfigure_confirm()
|
return await self.async_step_reconfigure_confirm()
|
||||||
|
|
||||||
@ -149,9 +149,6 @@ class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert self._entry is not None
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
if not user_input[CONF_HAS_PWD] or user_input.get(CONF_PASSWORD, "") == "":
|
if not user_input[CONF_HAS_PWD] or user_input.get(CONF_PASSWORD, "") == "":
|
||||||
user_input[CONF_PASSWORD] = ""
|
user_input[CONF_PASSWORD] = ""
|
||||||
@ -188,16 +185,13 @@ class SolarLogConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle flow upon an API authentication error."""
|
"""Handle flow upon an API authentication error."""
|
||||||
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
self._entry = self._get_reauth_entry()
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reauthorization flow."""
|
"""Handle reauthorization flow."""
|
||||||
|
|
||||||
assert self._entry is not None
|
|
||||||
|
|
||||||
if user_input and await self._test_extended_data(
|
if user_input and await self._test_extended_data(
|
||||||
self._entry.data[CONF_HOST], user_input.get(CONF_PASSWORD, "")
|
self._entry.data[CONF_HOST], user_input.get(CONF_PASSWORD, "")
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user