This commit is contained in:
J. Nick Koston 2025-04-16 19:22:41 -10:00
parent c64e647d8f
commit 66c6aa718e
No known key found for this signature in database
2 changed files with 26 additions and 8 deletions

View File

@ -452,23 +452,38 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
CONF_NOISE_PSK: self._noise_psk or "",
CONF_DEVICE_NAME: self._device_name,
}
config_options = {
CONF_ALLOW_SERVICE_CALLS: DEFAULT_NEW_CONFIG_ALLOW_ALLOW_SERVICE_CALLS,
}
if self.source == SOURCE_RECONFIGURE:
assert self.unique_id is not None
assert self._reconfig_entry.unique_id is not None
assert self._host is not None
assert self._device_name is not None
placeholders = {
"name": self._reconfig_entry.data.get(
CONF_DEVICE_NAME, self._reconfig_entry.title
),
"host": self._host,
"expected_mac": format_mac(self._reconfig_entry.unique_id),
}
for entry in self._async_current_entries(include_ignore=False):
if (
entry.entry_id != self._reconfig_entry.entry_id
and entry.data.get(CONF_DEVICE_NAME) == self._device_name
):
return self.async_abort(
reason="reconfigure_name_conflict",
description_placeholders={
**placeholders,
"existing_title": entry.title,
},
)
if self._reconfig_entry.unique_id != format_mac(self.unique_id):
return self.async_abort(
reason="reconfigure_unique_id_changed",
description_placeholders={
"name": self._reconfig_entry.title,
"host": self._host,
"expected_mac": format_mac(self._reconfig_entry.unique_id),
"unexpected_device_name": self._device_name,
**placeholders,
"unexpected_mac": format_mac(self.unique_id),
"unexpected_device_name": self._device_name,
},
)
return self.async_update_reload_and_abort(
@ -483,7 +498,9 @@ class EsphomeFlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_create_entry(
title=self._name,
data=config_data,
options=config_options,
options={
CONF_ALLOW_SERVICE_CALLS: DEFAULT_NEW_CONFIG_ALLOW_ALLOW_SERVICE_CALLS,
},
)
async def async_step_encryption_key(

View File

@ -12,6 +12,7 @@
"mqtt_missing_payload": "Missing MQTT Payload.",
"name_conflict_migrated": "The configuration for `{name}` has been migrated to a new device with MAC address `{mac}` from `{existing_mac}`.",
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
"reconfigure_name_conflict": "**Reconfiguration of `{name}` was aborted** because the address `{host}` points to a device named `{name}` (MAC: `{expected_mac}`), which is already in use by another configuration entry: `{existing_title}`.",
"reconfigure_unique_id_changed": "**Reconfiguration of `{name}` was aborted** because the address `{host}` points to a different device: `{unexpected_device_name}` (MAC: `{unexpected_mac}`) instead of the expected one (MAC: `{expected_mac}`)."
},
"error": {