Do not cache the entry in lamarzocco config flow (#128010)

pull/128038/head
epenet 2024-10-09 17:22:53 +02:00 committed by GitHub
parent 805bed092e
commit 11245dbb82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 11 deletions

View File

@ -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,
}
),