mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Improve BMW config flow (#133705)
This commit is contained in:
parent
4e316429d3
commit
78c9e47428
@ -103,9 +103,10 @@ class BMWConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
data: dict[str, Any] = {}
|
def __init__(self) -> None:
|
||||||
|
"""Initialize the config flow."""
|
||||||
_existing_entry_data: Mapping[str, Any] | None = None
|
self.data: dict[str, Any] = {}
|
||||||
|
self._existing_entry_data: dict[str, Any] = {}
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
@ -175,19 +176,15 @@ class BMWConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Show the change password step."""
|
"""Show the change password step."""
|
||||||
existing_data = (
|
|
||||||
dict(self._existing_entry_data) if self._existing_entry_data else {}
|
|
||||||
)
|
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
return await self.async_step_user(existing_data | user_input)
|
return await self.async_step_user(self._existing_entry_data | user_input)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="change_password",
|
step_id="change_password",
|
||||||
data_schema=RECONFIGURE_SCHEMA,
|
data_schema=RECONFIGURE_SCHEMA,
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
CONF_USERNAME: existing_data[CONF_USERNAME],
|
CONF_USERNAME: self._existing_entry_data[CONF_USERNAME],
|
||||||
CONF_REGION: existing_data[CONF_REGION],
|
CONF_REGION: self._existing_entry_data[CONF_REGION],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -195,14 +192,14 @@ class BMWConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
self._existing_entry_data = entry_data
|
self._existing_entry_data = dict(entry_data)
|
||||||
return await self.async_step_change_password()
|
return await self.async_step_change_password()
|
||||||
|
|
||||||
async def async_step_reconfigure(
|
async def async_step_reconfigure(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a reconfiguration flow initialized by the user."""
|
"""Handle a reconfiguration flow initialized by the user."""
|
||||||
self._existing_entry_data = self._get_reconfigure_entry().data
|
self._existing_entry_data = dict(self._get_reconfigure_entry().data)
|
||||||
return await self.async_step_change_password()
|
return await self.async_step_change_password()
|
||||||
|
|
||||||
async def async_step_captcha(
|
async def async_step_captcha(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user