mirror of
https://github.com/esphome/esphome.git
synced 2025-09-12 00:02:21 +01:00
fixes
This commit is contained in:
@@ -523,7 +523,7 @@ class EsphomeCore:
|
|||||||
# Key: platform name (e.g. "sensor", "binary_sensor"), Value: count
|
# Key: platform name (e.g. "sensor", "binary_sensor"), Value: count
|
||||||
self.platform_counts: defaultdict[str, int] = defaultdict(int)
|
self.platform_counts: defaultdict[str, int] = defaultdict(int)
|
||||||
# Track entity unique IDs to handle duplicates
|
# Track entity unique IDs to handle duplicates
|
||||||
# Set of (device_id, platform, object_id) tuples
|
# Set of (device_id, platform, sanitized_name) tuples
|
||||||
self.unique_ids: set[tuple[str, str, str]] = set()
|
self.unique_ids: set[tuple[str, str, str]] = set()
|
||||||
# Whether ESPHome was started in verbose mode
|
# Whether ESPHome was started in verbose mode
|
||||||
self.verbose = False
|
self.verbose = False
|
||||||
|
@@ -64,8 +64,7 @@ async def test_duplicate_entities_on_different_devices(
|
|||||||
temp_object_ids = set()
|
temp_object_ids = set()
|
||||||
|
|
||||||
for sensor in temp_sensors:
|
for sensor in temp_sensors:
|
||||||
device_id = getattr(sensor, "device_id", None)
|
temp_device_ids.add(sensor.device_id)
|
||||||
temp_device_ids.add(device_id)
|
|
||||||
temp_object_ids.add(sensor.object_id)
|
temp_object_ids.add(sensor.object_id)
|
||||||
|
|
||||||
# All should have object_id "temperature" (no suffix)
|
# All should have object_id "temperature" (no suffix)
|
||||||
@@ -128,19 +127,11 @@ async def test_duplicate_entities_on_different_devices(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Group by device
|
# Group by device
|
||||||
c1_buttons = [
|
c1_buttons = [b for b in empty_buttons if b.device_id == controller_1.device_id]
|
||||||
b
|
c2_buttons = [b for b in empty_buttons if b.device_id == controller_2.device_id]
|
||||||
for b in empty_buttons
|
|
||||||
if getattr(b, "device_id", 0) == controller_1.device_id
|
|
||||||
]
|
|
||||||
c2_buttons = [
|
|
||||||
b
|
|
||||||
for b in empty_buttons
|
|
||||||
if getattr(b, "device_id", 0) == controller_2.device_id
|
|
||||||
]
|
|
||||||
|
|
||||||
# For main device, device_id is 0
|
# For main device, device_id is 0
|
||||||
main_buttons = [b for b in empty_buttons if getattr(b, "device_id", 0) == 0]
|
main_buttons = [b for b in empty_buttons if b.device_id == 0]
|
||||||
|
|
||||||
# Check object IDs for empty name entities
|
# Check object IDs for empty name entities
|
||||||
assert len(c1_buttons) == 1 and c1_buttons[0].object_id == "controller_1"
|
assert len(c1_buttons) == 1 and c1_buttons[0].object_id == "controller_1"
|
||||||
|
Reference in New Issue
Block a user