Use reauth helpers in braviatv config flow (#127437)

pull/127505/head
epenet 2024-10-03 19:49:28 +02:00 committed by GitHub
parent 09014e3390
commit 0bbca596a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 12 deletions

View File

@ -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()