diff --git a/homeassistant/components/trafikverket_train/config_flow.py b/homeassistant/components/trafikverket_train/config_flow.py index d03eeca8f65..a9eefd09b9b 100644 --- a/homeassistant/components/trafikverket_train/config_flow.py +++ b/homeassistant/components/trafikverket_train/config_flow.py @@ -126,8 +126,6 @@ class TVTrainConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 - entry: ConfigEntry | None - @staticmethod @callback def async_get_options_flow( @@ -140,8 +138,6 @@ class TVTrainConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Handle re-authentication with Trafikverket.""" - - 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( @@ -153,26 +149,21 @@ class TVTrainConfigFlow(ConfigFlow, domain=DOMAIN): if user_input: api_key = user_input[CONF_API_KEY] - assert self.entry is not None + reauth_entry = self._get_reauth_entry() errors = await validate_input( self.hass, api_key, - self.entry.data[CONF_FROM], - self.entry.data[CONF_TO], - self.entry.data.get(CONF_TIME), - self.entry.data[CONF_WEEKDAY], - self.entry.options.get(CONF_FILTER_PRODUCT), + reauth_entry.data[CONF_FROM], + reauth_entry.data[CONF_TO], + reauth_entry.data.get(CONF_TIME), + reauth_entry.data[CONF_WEEKDAY], + reauth_entry.options.get(CONF_FILTER_PRODUCT), ) if not errors: - self.hass.config_entries.async_update_entry( - self.entry, - data={ - **self.entry.data, - CONF_API_KEY: api_key, - }, + return self.async_update_reload_and_abort( + reauth_entry, + data_updates={CONF_API_KEY: api_key}, ) - await self.hass.config_entries.async_reload(self.entry.entry_id) - return self.async_abort(reason="reauth_successful") return self.async_show_form( step_id="reauth_confirm",