mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use new reauth helpers in tailwind (#128755)
This commit is contained in:
parent
703e51d500
commit
8a16504988
@ -17,7 +17,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||||
from homeassistant.data_entry_flow import AbortFlow
|
from homeassistant.data_entry_flow import AbortFlow
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
@ -41,7 +41,6 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
host: str
|
host: str
|
||||||
reauth_entry: ConfigEntry | None = None
|
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
@ -148,9 +147,6 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle initiation of re-authentication with a Tailwind device."""
|
"""Handle initiation of re-authentication with a Tailwind device."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
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(
|
||||||
@ -159,10 +155,10 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle re-authentication with a Tailwind device."""
|
"""Handle re-authentication with a Tailwind device."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
if user_input is not None and self.reauth_entry:
|
if user_input is not None:
|
||||||
try:
|
try:
|
||||||
return await self._async_step_create_entry(
|
return await self._async_step_create_entry(
|
||||||
host=self.reauth_entry.data[CONF_HOST],
|
host=self._get_reauth_entry().data[CONF_HOST],
|
||||||
token=user_input[CONF_TOKEN],
|
token=user_input[CONF_TOKEN],
|
||||||
)
|
)
|
||||||
except TailwindAuthenticationError:
|
except TailwindAuthenticationError:
|
||||||
@ -214,9 +210,9 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
except TailwindUnsupportedFirmwareVersionError:
|
except TailwindUnsupportedFirmwareVersionError:
|
||||||
return self.async_abort(reason="unsupported_firmware")
|
return self.async_abort(reason="unsupported_firmware")
|
||||||
|
|
||||||
if self.reauth_entry:
|
if self.source == SOURCE_REAUTH:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self.reauth_entry,
|
self._get_reauth_entry(),
|
||||||
data={
|
data={
|
||||||
CONF_HOST: host,
|
CONF_HOST: host,
|
||||||
CONF_TOKEN: token,
|
CONF_TOKEN: token,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user