Use new reauth helpers in webostv (#128823)

pull/128730/head
epenet 2024-10-20 09:54:23 +02:00 committed by GitHub
parent 8ceecec5b8
commit 0ede15dcbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 6 deletions

View File

@ -47,7 +47,6 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
self._host: str = ""
self._name: str = ""
self._uuid: str | None = None
self._entry: ConfigEntry | None = None
@staticmethod
@callback
@ -144,15 +143,12 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult:
"""Perform reauth upon an WebOsTvPairError."""
self._host = entry_data[CONF_HOST]
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Dialog that informs the user that reauth is required."""
assert self._entry is not None
if user_input is not None:
try:
client = await async_control_connect(self._host, None)
@ -161,8 +157,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
except WEBOSTV_EXCEPTIONS:
return self.async_abort(reason="reauth_unsuccessful")
update_client_key(self.hass, self._entry, client)
await self.hass.config_entries.async_reload(self._entry.entry_id)
reauth_entry = self._get_reauth_entry()
update_client_key(self.hass, reauth_entry, client)
await self.hass.config_entries.async_reload(reauth_entry.entry_id)
return self.async_abort(reason="reauth_successful")
return self.async_show_form(step_id="reauth_confirm")