From bfcefbb8960d5a611b72a83ad54e944f8a4d2794 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 22 Oct 2026 13:40:46 +1300 Subject: [PATCH] [core] Assert sub-device relations in integration test (#21326) --- tests/integration/test_areas_and_devices.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_areas_and_devices.py b/tests/integration/test_areas_and_devices.py index 9d79f682c7b..135a112c366 100644 --- a/tests/integration/test_areas_and_devices.py +++ b/tests/integration/test_areas_and_devices.py @@ -4,7 +4,7 @@ from __future__ import annotations import asyncio -from aioesphomeapi import EntityState, SwitchInfo, SwitchState +from aioesphomeapi import DeviceRelation, EntityState, SwitchInfo, SwitchState import pytest from .types import APIClientConnectedFactory, RunCompiledFunction @@ -69,10 +69,19 @@ async def test_areas_and_devices( "Smart Switch should be in Kitchen" ) - # TODO: once aioesphomeapi with SubDeviceInfo.relation is pinned - # (esphome/aioesphomeapi#1955), assert the relations: Light Controller - # and Temperature Sensor VIA, Motion Detector and Smart Switch - # CHILD. The fixture mixes them so the per-device field path is built. + # The fixture mixes relations, so each device stores and sends its own + assert light_controller.relation == DeviceRelation.VIA, ( + "Light Controller should be a via device" + ) + assert temp_sensor.relation == DeviceRelation.VIA, ( + "Temperature Sensor should be a via device" + ) + assert motion_detector.relation == DeviceRelation.CHILD, ( + "Motion Detector should be a child device" + ) + assert smart_switch.relation == DeviceRelation.CHILD, ( + "Smart Switch should be a child device" + ) # Verify suggested_area is set to the top-level area name assert device_info.suggested_area == "Living Room", (