This commit is contained in:
J. Nick Koston
2025-06-24 23:40:16 +02:00
parent 591ec36f4a
commit ddbe17d3f6
2 changed files with 5 additions and 14 deletions

View File

@@ -523,7 +523,7 @@ class EsphomeCore:
# Key: platform name (e.g. "sensor", "binary_sensor"), Value: count
self.platform_counts: defaultdict[str, int] = defaultdict(int)
# 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()
# Whether ESPHome was started in verbose mode
self.verbose = False

View File

@@ -64,8 +64,7 @@ async def test_duplicate_entities_on_different_devices(
temp_object_ids = set()
for sensor in temp_sensors:
device_id = getattr(sensor, "device_id", None)
temp_device_ids.add(device_id)
temp_device_ids.add(sensor.device_id)
temp_object_ids.add(sensor.object_id)
# All should have object_id "temperature" (no suffix)
@@ -128,19 +127,11 @@ async def test_duplicate_entities_on_different_devices(
)
# Group by device
c1_buttons = [
b
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
]
c1_buttons = [b for b in empty_buttons if b.device_id == controller_1.device_id]
c2_buttons = [b for b in empty_buttons if b.device_id == controller_2.device_id]
# 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
assert len(c1_buttons) == 1 and c1_buttons[0].object_id == "controller_1"