mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 11:22:24 +01:00
[entity] Allow `device_id
` to be blank on entities (#10217)
This commit is contained in:
@@ -132,6 +132,7 @@ async def test_areas_and_devices(
|
||||
"Temperature Sensor Reading": temp_sensor.device_id,
|
||||
"Motion Detector Status": motion_detector.device_id,
|
||||
"Smart Switch Power": smart_switch.device_id,
|
||||
"Living Room Sensor": 0, # Main device
|
||||
}
|
||||
|
||||
for entity in sensor_entities:
|
||||
@@ -160,6 +161,18 @@ async def test_areas_and_devices(
|
||||
"Should have a switch with device_id 0 (main device)"
|
||||
)
|
||||
|
||||
# Verify extra switches with blank and none device_id are correctly available
|
||||
extra_switches = [
|
||||
e for e in switch_entities if e.name.startswith("Living Room")
|
||||
]
|
||||
assert len(extra_switches) == 2, (
|
||||
f"Expected 2 extra switches for Living Room, got {len(extra_switches)}"
|
||||
)
|
||||
extra_switch_device_ids = [e.device_id for e in extra_switches]
|
||||
assert all(d == 0 for d in extra_switch_device_ids), (
|
||||
"All extra switches should have device_id 0 (main device)"
|
||||
)
|
||||
|
||||
# Wait for initial states to be received for all switches
|
||||
await asyncio.wait_for(initial_states_future, timeout=2.0)
|
||||
|
||||
|
Reference in New Issue
Block a user