Use reauth helpers in frontier_silicon (#128569)

This commit is contained in:
epenet 2024-10-18 09:35:21 +02:00 committed by GitHub
parent 1e001469f6
commit 5fa6202111
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,7 +16,7 @@ from afsapi import (
import voluptuous as vol
from homeassistant.components import ssdp
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT
from .const import (
@ -58,7 +58,6 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
_name: str
_webfsapi_url: str
_reauth_entry: ConfigEntry | None = None # Only used in reauth flows
async def async_step_user(
self, user_input: dict[str, Any] | None = None
@ -178,11 +177,6 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult:
"""Perform reauth upon an API authentication error."""
self._webfsapi_url = entry_data[CONF_WEBFSAPI_URL]
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
)
return await self.async_step_device_config()
async def async_step_device_config(
@ -213,13 +207,11 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
if self._reauth_entry:
self.hass.config_entries.async_update_entry(
self._reauth_entry,
data={CONF_PIN: user_input[CONF_PIN]},
if self.source == SOURCE_REAUTH:
return self.async_update_reload_and_abort(
self._get_reauth_entry(),
data_updates={CONF_PIN: user_input[CONF_PIN]},
)
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
return self.async_abort(reason="reauth_successful")
try:
unique_id = await afsapi.get_radio_id()