Keep hub children when the child component list is missing (#1797)
Some checks failed
CI / Perform Lint Checks (3.14) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
Stale / stale (push) Has been cancelled

Fixes #1796

Some hubs intermittently return a `getChildDeviceComponentList` result
without the `child_component_list` key, as seen with an H200 (firmware 1.7.7 Build 20260917).

This changes the logic, so that when the list is missing, children are neither created nor deleted for
that update, and a debug message is logged. Treating the response as an
empty list would delete the known children of a hub that has some, so
they are kept until the next complete response.
This commit is contained in:
richard tristan
2026-10-24 18:16:16 +02:00
committed by GitHub
parent 0932f30d06
commit 78146d4e77
2 changed files with 43 additions and 2 deletions

View File

@@ -876,6 +876,19 @@ async def test_dynamic_devices(dev: Device, caplog: pytest.LogCaptureFixture) ->
expected_new_length -= 1
assert len(dev.children) == expected_new_length
# Test component list response without the list keeps the known children
saved_child_device_components = mock_child_device_components
mock_child_device_components = {}
with patch.object(
transport, "get_child_device_queries", side_effect=mock_get_child_device_queries
):
await dev.update()
assert len(dev.children) == expected_new_length
mock_child_device_components = saved_child_device_components
# Test no child devices
mock_child_device_info["child_device_list"] = []
@@ -890,6 +903,20 @@ async def test_dynamic_devices(dev: Device, caplog: pytest.LogCaptureFixture) ->
assert len(dev.children) == 0
# Test component list response without the list on a hub without children,
# as returned intermittently by some hubs (e.g. H200 firmware 1.7.7)
saved_child_device_components = mock_child_device_components
mock_child_device_components = {}
with patch.object(
transport, "get_child_device_queries", side_effect=mock_get_child_device_queries
):
await dev.update()
assert len(dev.children) == 0
mock_child_device_components = saved_child_device_components
# Logging tests are only for smartcam hubs as smart hubs do not test categories
if not isinstance(dev, SmartCamDevice):
return