mirror of
https://github.com/home-assistant/core.git
synced 2026-04-06 23:47:33 +00:00
Fix reconfigure flow in esphome uses create_entry (#154107)
This commit is contained in:
@@ -500,6 +500,16 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle creating a new entry by removing the old one and creating new."""
|
||||
assert self._entry_with_name_conflict is not None
|
||||
if self.source in (SOURCE_REAUTH, SOURCE_RECONFIGURE):
|
||||
return self.async_update_reload_and_abort(
|
||||
self._entry_with_name_conflict,
|
||||
title=self._name,
|
||||
unique_id=self.unique_id,
|
||||
data=self._async_make_config_data(),
|
||||
options={
|
||||
CONF_ALLOW_SERVICE_CALLS: DEFAULT_NEW_CONFIG_ALLOW_ALLOW_SERVICE_CALLS,
|
||||
},
|
||||
)
|
||||
await self.hass.config_entries.async_remove(
|
||||
self._entry_with_name_conflict.entry_id
|
||||
)
|
||||
|
||||
@@ -2208,7 +2208,6 @@ async def test_user_flow_name_conflict_overwrite(
|
||||
result["flow_id"], user_input={"next_step_id": "name_conflict_overwrite"}
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
assert result["data"] == {
|
||||
CONF_HOST: "127.0.0.1",
|
||||
CONF_PORT: 6053,
|
||||
@@ -2572,16 +2571,15 @@ async def test_reconfig_name_conflict_overwrite(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"next_step_id": "name_conflict_overwrite"}
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reconfigure_successful"
|
||||
|
||||
assert result["data"] == {
|
||||
CONF_HOST: "127.0.0.2",
|
||||
CONF_PORT: 6053,
|
||||
CONF_PASSWORD: "",
|
||||
CONF_NOISE_PSK: "",
|
||||
CONF_DEVICE_NAME: "test",
|
||||
}
|
||||
assert result["context"]["unique_id"] == "11:22:33:44:55:bb"
|
||||
assert (
|
||||
hass.config_entries.async_entry_for_domain_unique_id(
|
||||
DOMAIN, "11:22:33:44:55:bb"
|
||||
)
|
||||
is not None
|
||||
)
|
||||
assert (
|
||||
hass.config_entries.async_entry_for_domain_unique_id(
|
||||
DOMAIN, "11:22:33:44:55:aa"
|
||||
|
||||
Reference in New Issue
Block a user