Use reauth helpers in braviatv config flow (#127437)
parent
09014e3390
commit
0bbca596a9
|
@ -11,12 +11,7 @@ from pybravia import BraviaAuthError, BraviaClient, BraviaError, BraviaNotSuppor
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_REAUTH,
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_HOST, CONF_MAC, CONF_NAME, CONF_PIN
|
||||
from homeassistant.helpers import instance_id
|
||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||
|
@ -38,8 +33,6 @@ class BraviaTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
entry: ConfigEntry
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Initialize config flow."""
|
||||
self.client: BraviaClient | None = None
|
||||
|
@ -95,9 +88,9 @@ class BraviaTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
assert self.client
|
||||
await self.async_connect_device()
|
||||
|
||||
self.hass.config_entries.async_update_entry(self.entry, data=self.device_config)
|
||||
await self.hass.config_entries.async_reload(self.entry.entry_id)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
return self.async_update_reload_and_abort(
|
||||
self._get_reauth_entry(), data=self.device_config
|
||||
)
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
|
@ -252,6 +245,5 @@ class BraviaTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self.entry = self._get_reauth_entry()
|
||||
self.device_config = {**entry_data}
|
||||
return await self.async_step_authorize()
|
||||
|
|
Loading…
Reference in New Issue