mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Fix via_device in tplink linking to itself (#178228)
This commit is contained in:
@@ -233,7 +233,7 @@ class CoordinatedTPLinkEntity(CoordinatorEntity[TPLinkDataUpdateCoordinator], AB
|
||||
# are treated as one device.
|
||||
if (
|
||||
parent is not None
|
||||
and parent != registry_device
|
||||
and parent.device_id != registry_device.device_id
|
||||
and parent.device_type is not Device.Type.WallSwitch
|
||||
):
|
||||
self._attr_device_info["via_device_id"] = (
|
||||
|
||||
@@ -73,6 +73,10 @@
|
||||
'config_subentry_id': <ANY>,
|
||||
'configuration_url': None,
|
||||
'connections': set({
|
||||
tuple(
|
||||
'mac',
|
||||
'aa:bb:cc:dd:ee:ff',
|
||||
),
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'entry_type': None,
|
||||
@@ -93,6 +97,6 @@
|
||||
'name_by_user': None,
|
||||
'serial_number': None,
|
||||
'sw_version': '1.0.0',
|
||||
'via_device_id': <ANY>,
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
||||
|
||||
@@ -109,6 +109,26 @@ async def test_states(
|
||||
)
|
||||
|
||||
|
||||
async def test_device_does_not_link_via_self(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
mocked_hub: Device,
|
||||
) -> None:
|
||||
"""Test a child sharing its parent's device_id does not link to itself."""
|
||||
await setup_platform_for_device(
|
||||
hass, mock_config_entry, Platform.CLIMATE, mocked_hub
|
||||
)
|
||||
|
||||
devices = dr.async_entries_for_config_entry(
|
||||
device_registry, mock_config_entry.entry_id
|
||||
)
|
||||
assert devices
|
||||
for device in devices:
|
||||
assert device.via_device_id != device.id
|
||||
|
||||
|
||||
async def test_set_temperature(
|
||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mocked_hub: Device
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user