FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

When trying to set up a Tapo H200 Hub (with no child devices attached), the integration crashes during `_initialize_children()` with `RuntimeError: coroutine raised StopIteration`. · Issue #1728 · python-kasa/python-kasa · GitHub

Repository navigation

When trying to set up a Tapo H200 Hub (with no child devices attached), the integration crashes during _initialize_children() with RuntimeError: coroutine raised StopIteration. #1728

Open

Description

Logger: homeassistant.components.tplink
Source: config_entries.py:796
Integration: TP-Link Smart Home (documentation, issues)
First occurred: 3:41:29 PM (1 occurrence)
Last logged: 3:41:29 PM

Error setting up entry Tapo_Hub_BD34 H200 for tplink
Traceback (most recent call last):
File "/usr/local/lib/python3.14/site-packages/kasa/protocols/smartprotocol.py", line 381, in _handle_response_lists
response_list_name = next(
iter(
...<5 lines>...
)
)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 796, in __async_setup_with_context
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/tplink/init.py", line 169, in async_setup_entry
device: Device = await Device.connect(config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/kasa/device.py", line 247, in connect
return await connect(host=host, config=config) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/kasa/device_factory.py", line 80, in connect
return await _connect(config, protocol)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/kasa/device_factory.py", line 122, in _connect
await device.update()
File "/usr/local/lib/python3.14/site-packages/kasa/smart/smartdevice.py", line 271, in update
await self._negotiate()
File "/usr/local/lib/python3.14/site-packages/kasa/smartcam/smartcamdevice.py", line 222, in _negotiate
await self._initialize_children()
File "/usr/local/lib/python3.14/site-packages/kasa/smartcam/smartcamdevice.py", line 148, in _initialize_children
resp = await self.protocol.query(child_info_query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/kasa/protocols/smartprotocol.py", line 135, in query
return await self._query(request, retry_count)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/kasa/protocols/smartprotocol.py", line 140, in _query
return await self._execute_query(
^^^^^^^^^^^^^^^^^^^^^^^^^^
request, retry_count=retry, iterate_list_pages=True
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/kasa/protocols/smartcamprotocol.py", line 153, in _execute_query
return await self._execute_multiple_query(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
request, retry_count, iterate_list_pages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.14/site-packages/kasa/protocols/smartprotocol.py", line 300, in _execute_multiple_query
await self._handle_response_lists(
result, method, request_params, retry_count=retry_count
)
RuntimeError: coroutine raised StopIteration

Activity

  1. hubb22 commented on Aug 15, 2026

    Solution for this issue:

    Five edits across three files. The first adds a guard; the other four are the same substitution (direct index -> .get(key, [])), which behaves identically when the key is present, so hubs with paired children are unaffected.

    1. kasa/protocols/smartprotocol.py, in _handle_response_lists

    +        if list_sum == 0:
    +            return
    +
             response_list_name = next(
                 iter(

    2. kasa/smart/smartdevice.py

    -            for child in child_device_components_resp["child_component_list"]
    +            for child in child_device_components_resp.get("child_component_list", [])

    3. kasa/smart/smartdevice.py

    -        for info in child_device_resp["child_device_list"]:
    +        for info in child_device_resp.get("child_device_list", []):

    4. kasa/smart/smartdevice.py

    -            for info in child_info["child_device_list"]:
    +            for info in child_info.get("child_device_list", []):

    5. kasa/smartcam/smartcamdevice.py

    -            for info in child_info["child_device_list"]:
    +            for info in child_info.get("child_device_list", []):

    With all five applied, state completes cleanly on an empty hub, the device is usable, and the siren features (test_alarm / stop_alarm) work as expected. Behaviour with paired children is unchanged.

  2. ben-jardine commented on Sep 26, 2026

    Can confirm, the fix above does work for a H200.

    My H200 versions are:

    • Hardware: 1.0 (EU)
    • Firmware: 1.7.5 Build 20260806 rel.18204

    And I have also been getting the same error: RuntimeError: coroutine raised StopIteration during _initialize_children() / _handle_response_lists().

    Applied the five changes described above to a local checkout of python-kasa and tested it directly against the H200.

    The patched version now completes successfully:

    == Tapo H200 - H200 ==
    Host: [IP-ADDRESS]
    Port: 443
    Device state: True
    Hardware: 1.0 (EU)
    Firmware: 1.7.5 Build 20260806 rel.18204
    

    The H200 exposed the expected functionality.

  3. rossowl commented on Sep 30, 2026

    Yes, it works for me too.

    == tapo-hub - H200 ==
    Host:
    Port: 443
    Device state: True
    Time: 
    Hardware:     1.0 (EU)
    Firmware:     1.7.5 Build 20260806 rel.18204
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL