Skip to content

Commit

Permalink
Use reauth helpers in frontier_silicon (home-assistant#128569)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Oct 18, 2024
1 parent 1e00146 commit 5fa6202
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions homeassistant/components/frontier_silicon/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -178,11 +177,6 @@ async def async_step_reauth(
) -> 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(
Expand Down Expand Up @@ -213,13 +207,11 @@ async def async_step_device_config(
_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()
Expand Down

0 comments on commit 5fa6202

Please sign in to comment.