From fd8f5b9ff09d60e1e3a251583720652df54c2876 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sat, 19 Oct 2024 19:21:09 +0200 Subject: [PATCH] Use new reauth helpers in unifiprotect (#128775) --- .../components/unifiprotect/config_flow.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/unifiprotect/config_flow.py b/homeassistant/components/unifiprotect/config_flow.py index 284b7003485..6a9dc1210c0 100644 --- a/homeassistant/components/unifiprotect/config_flow.py +++ b/homeassistant/components/unifiprotect/config_flow.py @@ -104,7 +104,6 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Init the config flow.""" super().__init__() - self.entry: ConfigEntry | None = None self._discovered_device: dict[str, str] = {} async def async_step_dhcp( @@ -295,8 +294,6 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - - 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( @@ -304,21 +301,21 @@ class ProtectFlowHandler(ConfigFlow, domain=DOMAIN): ) -> ConfigFlowResult: """Confirm reauth.""" errors: dict[str, str] = {} - assert self.entry is not None # prepopulate fields - form_data = {**self.entry.data} + reauth_entry = self._get_reauth_entry() + form_data = {**reauth_entry.data} if user_input is not None: form_data.update(user_input) # validate login data _, errors = await self._async_get_nvr_data(form_data) if not errors: - return self.async_update_reload_and_abort(self.entry, data=form_data) + return self.async_update_reload_and_abort(reauth_entry, data=form_data) self.context["title_placeholders"] = { - "name": self.entry.title, - "ip_address": self.entry.data[CONF_HOST], + "name": reauth_entry.title, + "ip_address": reauth_entry.data[CONF_HOST], } return self.async_show_form( step_id="reauth_confirm",