mirror of
https://github.com/esphome/esphome.git
synced 2025-10-06 11:53:45 +01:00
fixes
This commit is contained in:
@@ -1,211 +0,0 @@
|
||||
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: []
|
@@ -0,0 +1,154 @@
|
||||
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
|
||||
- id: controller_3
|
||||
name: Controller 3
|
||||
|
||||
host:
|
||||
api: # Port will be automatically injected
|
||||
logger:
|
||||
|
||||
# Test that duplicate entity names are allowed on different devices
|
||||
|
||||
# Scenario 1: Same sensor name on different devices (allowed)
|
||||
sensor:
|
||||
- platform: template
|
||||
name: Temperature
|
||||
device_id: controller_1
|
||||
lambda: return 21.0;
|
||||
update_interval: 0.1s
|
||||
|
||||
- platform: template
|
||||
name: Temperature
|
||||
device_id: controller_2
|
||||
lambda: return 22.0;
|
||||
update_interval: 0.1s
|
||||
|
||||
- platform: template
|
||||
name: Temperature
|
||||
device_id: controller_3
|
||||
lambda: return 23.0;
|
||||
update_interval: 0.1s
|
||||
|
||||
# Main device sensor (no device_id)
|
||||
- platform: template
|
||||
name: Temperature
|
||||
lambda: return 20.0;
|
||||
update_interval: 0.1s
|
||||
|
||||
# Different sensor with unique name
|
||||
- platform: template
|
||||
name: Humidity
|
||||
lambda: return 60.0;
|
||||
update_interval: 0.1s
|
||||
|
||||
# Scenario 2: Same binary sensor name on different devices (allowed)
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
name: Status
|
||||
device_id: controller_1
|
||||
lambda: return true;
|
||||
|
||||
- platform: template
|
||||
name: Status
|
||||
device_id: controller_2
|
||||
lambda: return false;
|
||||
|
||||
- platform: template
|
||||
name: Status
|
||||
lambda: return true; # Main device
|
||||
|
||||
# Different platform can have same name as sensor
|
||||
- platform: template
|
||||
name: Temperature
|
||||
lambda: return true;
|
||||
|
||||
# Scenario 3: Same text sensor name on different devices
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: Device Info
|
||||
device_id: controller_1
|
||||
lambda: return {"Controller 1 Active"};
|
||||
update_interval: 0.1s
|
||||
|
||||
- platform: template
|
||||
name: Device Info
|
||||
device_id: controller_2
|
||||
lambda: return {"Controller 2 Active"};
|
||||
update_interval: 0.1s
|
||||
|
||||
- platform: template
|
||||
name: Device Info
|
||||
lambda: return {"Main Device Active"};
|
||||
update_interval: 0.1s
|
||||
|
||||
# Scenario 4: Same switch name on different devices
|
||||
switch:
|
||||
- platform: template
|
||||
name: Power
|
||||
device_id: controller_1
|
||||
lambda: return false;
|
||||
turn_on_action: []
|
||||
turn_off_action: []
|
||||
|
||||
- platform: template
|
||||
name: Power
|
||||
device_id: controller_2
|
||||
lambda: return true;
|
||||
turn_on_action: []
|
||||
turn_off_action: []
|
||||
|
||||
- platform: template
|
||||
name: Power
|
||||
device_id: controller_3
|
||||
lambda: return false;
|
||||
turn_on_action: []
|
||||
turn_off_action: []
|
||||
|
||||
# Unique switch on main device
|
||||
- platform: template
|
||||
name: Main Power
|
||||
lambda: return true;
|
||||
turn_on_action: []
|
||||
turn_off_action: []
|
||||
|
||||
# Scenario 5: Empty names on different devices (should use device name)
|
||||
button:
|
||||
- platform: template
|
||||
name: ""
|
||||
device_id: controller_1
|
||||
on_press: []
|
||||
|
||||
- platform: template
|
||||
name: ""
|
||||
device_id: controller_2
|
||||
on_press: []
|
||||
|
||||
- platform: template
|
||||
name: ""
|
||||
on_press: [] # Main device
|
||||
|
||||
# Scenario 6: Special characters in names
|
||||
number:
|
||||
- platform: template
|
||||
name: "Temperature Setpoint!"
|
||||
device_id: controller_1
|
||||
min_value: 10.0
|
||||
max_value: 30.0
|
||||
step: 0.1
|
||||
lambda: return 21.0;
|
||||
set_action: []
|
||||
|
||||
- platform: template
|
||||
name: "Temperature Setpoint!"
|
||||
device_id: controller_2
|
||||
min_value: 10.0
|
||||
max_value: 30.0
|
||||
step: 0.1
|
||||
lambda: return 22.0;
|
||||
set_action: []
|
Reference in New Issue
Block a user