mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Use reauth helpers in frontier_silicon (#128569)
This commit is contained in:
parent
1e001469f6
commit
5fa6202111
@ -16,7 +16,7 @@ from afsapi import (
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
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 homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -58,7 +58,6 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
_name: str
|
_name: str
|
||||||
_webfsapi_url: str
|
_webfsapi_url: str
|
||||||
_reauth_entry: ConfigEntry | None = None # Only used in reauth flows
|
|
||||||
|
|
||||||
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
|
||||||
@ -178,11 +177,6 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self._webfsapi_url = entry_data[CONF_WEBFSAPI_URL]
|
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()
|
return await self.async_step_device_config()
|
||||||
|
|
||||||
async def async_step_device_config(
|
async def async_step_device_config(
|
||||||
@ -213,13 +207,11 @@ class FrontierSiliconConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
if self._reauth_entry:
|
if self.source == SOURCE_REAUTH:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(
|
||||||
self._reauth_entry,
|
self._get_reauth_entry(),
|
||||||
data={CONF_PIN: user_input[CONF_PIN]},
|
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:
|
try:
|
||||||
unique_id = await afsapi.get_radio_id()
|
unique_id = await afsapi.get_radio_id()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user