From 11245dbb82f379e3330f9cca990c89209bf8cb53 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:22:53 +0200 Subject: [PATCH] Do not cache the entry in lamarzocco config flow (#128010) --- .../components/lamarzocco/config_flow.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/lamarzocco/config_flow.py b/homeassistant/components/lamarzocco/config_flow.py index 898a93a014a..0c359a53631 100644 --- a/homeassistant/components/lamarzocco/config_flow.py +++ b/homeassistant/components/lamarzocco/config_flow.py @@ -54,9 +54,6 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 2 - reauth_entry: ConfigEntry - reconfigure_entry: ConfigEntry - def __init__(self) -> None: """Initialize the config flow.""" self._config: dict[str, Any] = {} @@ -73,7 +70,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): if user_input: data: dict[str, Any] = {} if self.source == SOURCE_REAUTH: - data = dict(self.reauth_entry.data) + data = dict(self._get_reauth_entry().data) data = { **data, **user_input, @@ -99,7 +96,7 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): if not errors: if self.source == SOURCE_REAUTH: return self.async_update_reload_and_abort( - self.reauth_entry, data=data, reason="reauth_successful" + self._get_reauth_entry(), data=data ) if self._discovered: if self._discovered[CONF_MACHINE] not in self._fleet: @@ -208,12 +205,11 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): if user_input is not None: return self.async_update_reload_and_abort( - self.reconfigure_entry, + self._get_reconfigure_entry(), data={ **self._config, CONF_MAC: user_input[CONF_MAC], }, - reason="reconfigure_successful", ) bt_options = [ @@ -266,7 +262,6 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """Perform reauth upon an API authentication error.""" - self.reauth_entry = self._get_reauth_entry() return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( @@ -289,7 +284,6 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Perform reconfiguration of the config entry.""" - self.reconfigure_entry = self._get_reconfigure_entry() return await self.async_step_reconfigure_confirm() async def async_step_reconfigure_confirm( @@ -297,17 +291,18 @@ class LmConfigFlow(ConfigFlow, domain=DOMAIN): ) -> ConfigFlowResult: """Confirm reconfiguration of the device.""" if not user_input: + reconfigure_entry = self._get_reconfigure_entry() return self.async_show_form( step_id="reconfigure_confirm", data_schema=vol.Schema( { vol.Required( CONF_USERNAME, - default=self.reconfigure_entry.data[CONF_USERNAME], + default=reconfigure_entry.data[CONF_USERNAME], ): str, vol.Required( CONF_PASSWORD, - default=self.reconfigure_entry.data[CONF_PASSWORD], + default=reconfigure_entry.data[CONF_PASSWORD], ): str, } ),