From f6c7ade579197794afd0f4c9f5d477ba31bd5f38 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:23:24 +0200 Subject: [PATCH] Use _get_reauth/reconfigure_entry in fritzbox (#127284) --- homeassistant/components/fritzbox/config_flow.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/fritzbox/config_flow.py b/homeassistant/components/fritzbox/config_flow.py index 8cee1e37fd3..43463c01afe 100644 --- a/homeassistant/components/fritzbox/config_flow.py +++ b/homeassistant/components/fritzbox/config_flow.py @@ -43,9 +43,10 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 + _entry: ConfigEntry + def __init__(self) -> None: """Initialize flow.""" - self._entry: ConfigEntry | None = None self._host: str | None = None self._name: str | None = None self._password: str | None = None @@ -62,7 +63,6 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN): ) async def _update_entry(self) -> None: - assert self._entry is not None self.hass.config_entries.async_update_entry( self._entry, data={ @@ -184,9 +184,7 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Trigger a reauthentication flow.""" - entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) - assert entry is not None - self._entry = entry + self._entry = self._get_reauth_entry() self._host = entry_data[CONF_HOST] self._name = str(entry_data[CONF_HOST]) self._username = entry_data[CONF_USERNAME] @@ -228,9 +226,7 @@ class FritzboxConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle a reconfiguration flow initialized by the user.""" - entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) - assert entry is not None - self._entry = entry + self._entry = self._get_reconfigure_entry() self._name = self._entry.data[CONF_HOST] self._host = self._entry.data[CONF_HOST] self._username = self._entry.data[CONF_USERNAME]