mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	preen
This commit is contained in:
		| @@ -238,7 +238,7 @@ def entity_duplicate_validator(platform: str) -> Callable[[ConfigType], ConfigTy | ||||
|  | ||||
|             # Show both original names and their ASCII-only versions if they differ | ||||
|             sanitized_msg = "" | ||||
|             if entity_name != name_key or existing_name != name_key: | ||||
|             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}'" | ||||
|   | ||||
| @@ -730,3 +730,23 @@ def test_entity_duplicate_validator_non_ascii_names() -> None: | ||||
|         ), | ||||
|     ): | ||||
|         validator(config2) | ||||
|  | ||||
|  | ||||
| def test_entity_duplicate_validator_same_name_no_enhanced_message() -> None: | ||||
|     """Test that identical names don't show the enhanced message.""" | ||||
|     # Create validator for sensor platform | ||||
|     validator = entity_duplicate_validator("sensor") | ||||
|  | ||||
|     # First entity should pass | ||||
|     config1 = {CONF_NAME: "Temperature"} | ||||
|     validated1 = validator(config1) | ||||
|     assert validated1 == config1 | ||||
|  | ||||
|     # Second entity with exact same name should fail without enhanced message | ||||
|     config2 = {CONF_NAME: "Temperature"} | ||||
|     with pytest.raises( | ||||
|         Invalid, | ||||
|         match=r"Duplicate sensor entity with name 'Temperature' found.*" | ||||
|         r"Each entity on a device must have a unique name within its platform\.$", | ||||
|     ): | ||||
|         validator(config2) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user