Use new reauth helpers in tailwind (#128755)

This commit is contained in:
epenet 2024-10-19 14:43:31 +02:00 committed by GitHub
parent 703e51d500
commit 8a16504988
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,7 +17,7 @@ import voluptuous as vol
from homeassistant.components import zeroconf
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.data_entry_flow import AbortFlow
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -41,7 +41,6 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
VERSION = 1
host: str
reauth_entry: ConfigEntry | None = None
async def async_step_user(
self, user_input: dict[str, Any] | None = None
@ -148,9 +147,6 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""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()
async def async_step_reauth_confirm(
@ -159,10 +155,10 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle re-authentication with a Tailwind device."""
errors = {}
if user_input is not None and self.reauth_entry:
if user_input is not None:
try:
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],
)
except TailwindAuthenticationError:
@ -214,9 +210,9 @@ class TailwindFlowHandler(ConfigFlow, domain=DOMAIN):
except TailwindUnsupportedFirmwareVersionError:
return self.async_abort(reason="unsupported_firmware")
if self.reauth_entry:
if self.source == SOURCE_REAUTH:
return self.async_update_reload_and_abort(
self.reauth_entry,
self._get_reauth_entry(),
data={
CONF_HOST: host,
CONF_TOKEN: token,