Skip to content

Commit 0f7b0c1

Browse files
committed
test: enabled switch is a FormulaMetric — entity_id keeps the doubled prefix
test_sensor_complex[complex_naming] expected the de-duplicated entity_id for the schedule 'enabled' switch, but that entity is a WritableFormulaMetric: formula metrics are created without a display_id, so display_id == unique_id and the device-type prefix is NOT de-duplicated (system_0_system_ess..., like the energy FormulaMetric). The 'Day' select is a plain topic metric and stays de-duplicated. Fixes the StopIteration (no entity matched the expected id).
1 parent 07714d6 commit 0f7b0c1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/test_hub.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,12 @@ async def test_sensor_complex(
381381
day_entity_id = "select.victron_venus_ess_batterylife_schedule_charge_2_days"
382382
enabled_entity_id = "switch.victron_venus_ess_batterylife_schedule_charge_2_enabled"
383383
else:
384+
# The "Day" select is a plain topic metric, so its display_id de-duplicates
385+
# the device-type prefix (system_system -> system). The "enabled" switch is
386+
# a (writable) FormulaMetric, which has no display_id and keeps the full
387+
# unique_id (doubled system_ prefix) — so its entity_id is NOT de-duplicated.
384388
day_entity_id = "select.victron_mqtt_123_system_0_ess_schedule_charge_2_days"
385-
enabled_entity_id = "switch.victron_mqtt_123_system_0_ess_schedule_charge_2_enabled"
389+
enabled_entity_id = "switch.victron_mqtt_123_system_0_system_ess_schedule_charge_2_enabled"
386390

387391
day_entity = next(entity for entity in entities if entity.entity_id == day_entity_id)
388392
enabled_entity = next(

0 commit comments

Comments
 (0)