mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Merge branch 'multi_device' into integration
This commit is contained in:
		
							
								
								
									
										211
									
								
								tests/integration/fixtures/duplicate_entities.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										211
									
								
								tests/integration/fixtures/duplicate_entities.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,211 @@ | ||||
| esphome: | ||||
|   name: duplicate-entities-test | ||||
|   # Define devices to test multi-device duplicate handling | ||||
|   devices: | ||||
|     - id: controller_1 | ||||
|       name: Controller 1 | ||||
|     - id: controller_2 | ||||
|       name: Controller 2 | ||||
|  | ||||
| host: | ||||
| api:  # Port will be automatically injected | ||||
| logger: | ||||
|  | ||||
| # Create duplicate entities across different scenarios | ||||
|  | ||||
| # Scenario 1: Multiple sensors with same name on same device (should get _2, _3, _4) | ||||
| sensor: | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return 1.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return 2.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return 3.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return 4.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   # Scenario 2: Device-specific duplicates using device_id configuration | ||||
|   - platform: template | ||||
|     name: Device Temperature | ||||
|     device_id: controller_1 | ||||
|     lambda: return 10.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: Device Temperature | ||||
|     device_id: controller_1 | ||||
|     lambda: return 11.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: Device Temperature | ||||
|     device_id: controller_1 | ||||
|     lambda: return 12.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   # Different device, same name - should not conflict | ||||
|   - platform: template | ||||
|     name: Device Temperature | ||||
|     device_id: controller_2 | ||||
|     lambda: return 20.0; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
| # Scenario 3: Binary sensors (different platform, same name) | ||||
| binary_sensor: | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return true; | ||||
|  | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return false; | ||||
|  | ||||
|   - platform: template | ||||
|     name: Temperature | ||||
|     lambda: return true; | ||||
|  | ||||
|   # Scenario 5: Binary sensors on devices | ||||
|   - platform: template | ||||
|     name: Device Temperature | ||||
|     device_id: controller_1 | ||||
|     lambda: return true; | ||||
|  | ||||
|   - platform: template | ||||
|     name: Device Temperature | ||||
|     device_id: controller_2 | ||||
|     lambda: return false; | ||||
|  | ||||
|   # Issue #6953: Empty names on binary sensors | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return true; | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return false; | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return true; | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return false; | ||||
|  | ||||
| # Scenario 6: Test with special characters that need sanitization | ||||
| text_sensor: | ||||
|   - platform: template | ||||
|     name: "Status Message!" | ||||
|     lambda: return {"status1"}; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: "Status Message!" | ||||
|     lambda: return {"status2"}; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
|   - platform: template | ||||
|     name: "Status Message!" | ||||
|     lambda: return {"status3"}; | ||||
|     update_interval: 0.1s | ||||
|  | ||||
| # Scenario 7: More switch duplicates | ||||
| switch: | ||||
|   - platform: template | ||||
|     name: "Power Switch" | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "Power Switch" | ||||
|     lambda: return true; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   # Scenario 8: Issue #6953 - Multiple entities with empty names | ||||
|   # Empty names on main device - should use device name with suffixes | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return true; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   # Scenario 9: Issue #6953 - Empty names on sub-devices | ||||
|   # Empty names on sub-device - should use sub-device name with suffixes | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     device_id: controller_1 | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     device_id: controller_1 | ||||
|     lambda: return true; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     device_id: controller_1 | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   # Empty names on different sub-device | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     device_id: controller_2 | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "" | ||||
|     device_id: controller_2 | ||||
|     lambda: return true; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   # Scenario 10: Issue #6953 - Duplicate "xyz" names | ||||
|   - platform: template | ||||
|     name: "xyz" | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "xyz" | ||||
|     lambda: return true; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
|  | ||||
|   - platform: template | ||||
|     name: "xyz" | ||||
|     lambda: return false; | ||||
|     turn_on_action: [] | ||||
|     turn_off_action: [] | ||||
		Reference in New Issue
	
	Block a user