mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 00:05:43 +00:00
[core] Improve error reporting for entity name conflicts with non-ASCII characters (#10329)
This commit is contained in:
@@ -236,10 +236,21 @@ def entity_duplicate_validator(platform: str) -> Callable[[ConfigType], ConfigTy
|
||||
if existing_component != "unknown":
|
||||
conflict_msg += f" from component '{existing_component}'"
|
||||
|
||||
# Show both original names and their ASCII-only versions if they differ
|
||||
sanitized_msg = ""
|
||||
if entity_name != existing_name:
|
||||
sanitized_msg = (
|
||||
f"\n Original names: '{entity_name}' and '{existing_name}'"
|
||||
f"\n Both convert to ASCII ID: '{name_key}'"
|
||||
"\n To fix: Add unique ASCII characters (e.g., '1', '2', or 'A', 'B')"
|
||||
"\n to distinguish them"
|
||||
)
|
||||
|
||||
raise cv.Invalid(
|
||||
f"Duplicate {platform} entity with name '{entity_name}' found{device_prefix}. "
|
||||
f"{conflict_msg}. "
|
||||
f"Each entity on a device must have a unique name within its platform."
|
||||
"Each entity on a device must have a unique name within its platform."
|
||||
f"{sanitized_msg}"
|
||||
)
|
||||
|
||||
# Store metadata about this entity
|
||||
|
||||
Reference in New Issue
Block a user