Use new reauth_helpers in onvif (#128705)

This commit is contained in:
epenet 2024-10-19 09:50:05 +02:00 committed by GitHub
parent 5816342bed
commit 157e7f9f78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,7 +102,6 @@ class OnvifFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a ONVIF config flow."""
VERSION = 1
_reauth_entry: ConfigEntry
@staticmethod
@callback
@ -136,30 +135,28 @@ class OnvifFlowHandler(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle re-authentication of an existing config entry."""
reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
)
assert reauth_entry is not None
self._reauth_entry = reauth_entry
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Confirm reauth."""
entry = self._reauth_entry
errors: dict[str, str] | None = {}
reauth_entry = self._get_reauth_entry()
description_placeholders: dict[str, str] | None = None
if user_input is not None:
entry_data = entry.data
self.onvif_config = entry_data | user_input
self.onvif_config = reauth_entry.data | user_input
errors, description_placeholders = await self.async_setup_profiles(
configure_unique_id=False
)
if not errors:
return self.async_update_reload_and_abort(entry, data=self.onvif_config)
return self.async_update_reload_and_abort(
reauth_entry, data=self.onvif_config
)
username = (user_input or {}).get(CONF_USERNAME) or entry.data[CONF_USERNAME]
username = (user_input or {}).get(CONF_USERNAME) or reauth_entry.data[
CONF_USERNAME
]
return self.async_show_form(
step_id="reauth_confirm",
data_schema=vol.Schema(