From 7a77a3d7cea0778bee41acf5e0569b2d5a83cc47 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:24:26 +0200 Subject: [PATCH] Use reauth helpers in jellyfin (#128648) --- homeassistant/components/jellyfin/config_flow.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/jellyfin/config_flow.py b/homeassistant/components/jellyfin/config_flow.py index 7b5426cffde..f60d96f3efa 100644 --- a/homeassistant/components/jellyfin/config_flow.py +++ b/homeassistant/components/jellyfin/config_flow.py @@ -56,7 +56,6 @@ class JellyfinConfigFlow(ConfigFlow, domain=DOMAIN): def __init__(self) -> None: """Initialize the Jellyfin config flow.""" self.client_device_id: str | None = None - self.entry: JellyfinConfigEntry | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None @@ -108,7 +107,6 @@ class JellyfinConfigFlow(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( @@ -118,8 +116,8 @@ class JellyfinConfigFlow(ConfigFlow, domain=DOMAIN): errors: dict[str, str] = {} if user_input is not None: - assert self.entry is not None - new_input = self.entry.data | user_input + reauth_entry = self._get_reauth_entry() + new_input = reauth_entry.data | user_input if self.client_device_id is None: self.client_device_id = _generate_client_device_id() @@ -135,10 +133,7 @@ class JellyfinConfigFlow(ConfigFlow, domain=DOMAIN): errors["base"] = "unknown" _LOGGER.exception("Unexpected exception") else: - self.hass.config_entries.async_update_entry(self.entry, data=new_input) - - 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(reauth_entry, data=new_input) return self.async_show_form( step_id="reauth_confirm", data_schema=REAUTH_DATA_SCHEMA, errors=errors