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

IoT HomeKit query ordering causes update timeouts for legacy devices in 0.11.0.1 · Issue #1791 · python-kasa/python-kasa · GitHub

Repository navigation

IoT HomeKit query ordering causes update timeouts for legacy devices in 0.11.0.1 #1791

Open

Description

Summary

Some legacy Kasa plugs stopped updating after Home Assistant 2026.10.0 to 2026.10.1, which changes its python-kasa requirement from 0.10.2 to 0.11.0.1. I reproduced the failure outside Home Assistant and isolated it to the ordering of the IoT HomeKit probe added in #1566.

On the affected devices, a request containing system.get_sysinfo followed by smartlife.iot.homekit.setup_info_get times out. Reversing those two module keys works, and querying HomeKit alone immediately returns {"err_code":-1,"err_msg":"module not support"}. Keeping HomeKit in a separate request restores normal updates.

This adds a minimal protocol reproduction and testing on three additional models to the HomeKit-probe regression reported in #1788.

Affected devices

The complete update failure and candidate fix were tested on four HS103, two EP10 and one KP115. The detailed request-ordering experiment and old-release comparison were performed on one representative of each model:

Model Hardware Firmware reported by the device
EP10(US) 1.0 1.0.2 Build 200915 Rel.085940
HS103(US) 5.0 1.0.3 Build 201015 Rel.142523
KP115(US) 1.0 1.0.7 Build 200825 Rel.100128

The tested devices do not expose the HomeKit module; the standalone query returns an explicit unsupported-module response.

Reproduction

Run this against an affected device using the legacy XOR protocol on TCP port 9999:

import asyncio
import sys

from kasa.iot import IotPlug


async def main():
    device = IotPlug(sys.argv[1])
    try:
        await device.update()
        await device.update()
    finally:
        await device.disconnect()


asyncio.run(main())

With published 0.10.2, both updates succeed. With published 0.11.0.1, the initial update fails with:

kasa.exceptions.TimeoutError: Timeout after 5 seconds sending request to the device DEVICE_IP:9999:

Minimal failing request

{"system":{"get_sysinfo":{}},"smartlife.iot.homekit":{"setup_info_get":{}}}

TCP connects successfully. The timeout occurs in XorTransport._execute_send() while awaiting the first four-byte response header, at self.reader.readexactly(self.BLOCK_SIZE).

Same queries, reversed order: succeeds

{"smartlife.iot.homekit":{"setup_info_get":{}},"system":{"get_sysinfo":{}}}

The response contains both system information and the HomeKit unsupported-module error.

Standalone HomeKit query: succeeds

Request:

{"smartlife.iot.homekit":{"setup_info_get":{}}}

Response:

{"smartlife.iot.homekit":{"err_code":-1,"err_msg":"module not support"}}

Standalone system.get_sysinfo and normal update batches without HomeKit also succeed. Fresh connections were used between requests in the ordering experiment. Reordering the same commands without changing the payload length is sufficient to change the outcome, which isolates this from a general connectivity failure or merely exceeding a request/response-size limit. The firmware's internal parser implementation is unknown.

Tests performed

Configuration EP10 HS103 KP115
Published 0.10.2, two updates Pass Pass Pass, including energy readings
Published 0.11.0.1, initial update Timeout Timeout Timeout
0.11.0.1 with a standalone HomeKit probe before the regular batch Two updates pass Two updates pass Two updates pass, including energy readings
Candidate patch keeping HomeKit requests separate Two updates pass Two updates pass Two updates pass, including energy readings
Candidate patch on Python 3.14, disconnect between updates Pass Pass Pass, including energy readings

Proposed fix

Send HomeKit in its own request from the shared IoT modular-update path, then merge its response normally. The existing module support detection caches the unsupported response and omits HomeKit on subsequent updates. This retains HomeKit support without a firmware/model list or interpreting genuine communication timeouts as proof that a feature is unsupported.

The local candidate passes on all seven affected plugs. Supported HomeKit behavior is covered with the existing EP25 fixture; HS110 beta-firmware confirmation is still needed.

Related reports

Activity

  1. changed the title [-]IoT HomeKit query ordering causes EP10, HS103 and KP115 update timeouts in 0.11.0.1[/-] [+]IoT HomeKit query ordering causes update timeouts for legacy devices in 0.11.0.1[/+] on Oct 11, 2026
  2. ewalker101 commented on Oct 11, 2026

    Additional data point confirming this on KP115(US) hw 1.0 / fw 1.0.7 Build 200825 Rel.100128 (identical firmware to the KP115 above), plus results suggesting the trigger is not HomeKit-specific.

    Raw XOR probes, one TCP connection each, 10 s timeout:

    request (module order) result
    system, homekit no response
    system, foo.bar (made-up module) no response
    homekit, system reply
    system, time, homekit reply (repeated 3×)
    system, time, foo.bar reply
    time, homekit reply
    full 0.11.0.1 initial batch, homekit moved last reply (2647 B)
    full 0.11.0.1 initial batch, homekit after system no response

    A made-up module placed directly after system hangs exactly like HomeKit, while any other position works. So on this firmware the trigger appears to be any unsupported module immediately following system, not HomeKit specifically. Size is ruled out (a 75 B request hangs while the 381 B 0.10.2 batch with a 2575 B reply works).

    Suggestion: in addition to sending HomeKit separately, it may be worth probing any newly introduced iot module in its own request on first update, so a future module doesn't reintroduce the same failure on these devices.

    Happy to test a candidate branch against this device.

  3. igiannakas commented on Oct 13, 2026

    Confirming this on HS110(UK) hw 4.1, fw 1.1.1 Build 201203 Rel.135822 also

  4. psiberfunk commented on Oct 15, 2026

    Confirming the same regression on two additional physical EP10(US) plugs, both with:

    • Hardware: 1.0
    • Firmware: 1.0.2 Build 200915 Rel.085940, read directly from each device
    • Home Assistant Core: 2026.10.1

    Both had been working normally. Their HA entities became unavailable together on October 11, immediately after the Core update, and the integration now repeatedly fails setup with Timeout after 5 seconds sending request to the device ...:9999.

    I reproduced the request-order failure directly on both plugs, outside HA, using raw XOR requests over TCP port 9999. Each request used a fresh TCP connection and a 4-second socket timeout:

    Read-only request Plug A Plug B
    system.get_sysinfo alone Reply, 0.023 s Reply, 0.056 s
    system.get_sysinfo followed by smartlife.iot.homekit.setup_info_get Timeout, 4.012 s Timeout, 4.096 s
    Same two queries with HomeKit first, then system Reply, 0.111 s Reply, 0.139 s
    system.get_sysinfo alone again afterward Reply, 0.149 s Reply, 0.110 s

    The reversed-order response includes valid system information and "smartlife.iot.homekit":{"err_code":-1,"err_msg":"module not support"} on both units. TCP connection establishment succeeds for the failing request; it times out waiting for a response.

    This independently confirms the reported request-order regression on this exact EP10 hardware/firmware combination. At the time of this initial report I had not tested PR #1792; the follow-up below records the subsequent successful backport tests. No Home Assistant rollback was performed.


    Follow-up: verified PR #1792's production change on both EP10s, including inside Home Assistant

    I have now tested the exact _modular_update replacement from PR #1792, commit ee5061e37ccad6bd95cd2cacaa812a9db773817f, on the two EP10(US) hardware 1.0 / firmware 1.0.2 Build 200915 Rel.085940 plugs reported above.

    Results:

    • Isolated test on macOS / Python 3.14: installed published python-kasa==0.11.0.1; confirmed an initial update timed out on each real plug; applied the guarded replacement in that Python process; then both plugs completed two consecutive updates successfully, disconnecting between updates. Patched updates took approximately 0.12–0.27 seconds. These tests issued only status queries.
    • Live Home Assistant OS 18.3 / Core 2026.10.1: installed a temporary startup custom integration that applies the same method replacement in memory, then restarted HA. The startup log confirmed the patch applied. Both previously failing TP-Link config entries became loaded, and both switch entities recovered from unavailable.
    • Actual control verification: used HA's switch.turn_on and switch.turn_off services on both plugs. Separate direct system.get_sysinfo reads confirmed both real relays changed to relay_state: 1 and then 0. HA's entity states followed asynchronously, settling in roughly one second. Both plugs were restored to their initial off state.
    • Three other previously working EP10 entries that had failed at the same time also returned to loaded; I did not exercise their relays.

    How the temporary HA backport was applied:

    1. Copied the candidate _modular_update method unchanged from the pinned commit into a small local custom component. Its manifest declares dependencies: ["tplink"].
    2. Its async_setup runs an installer via hass.async_add_executor_job. The installer requires exactly python-kasa==0.11.0.1 and verifies SHA-256 fingerprints of both the original method's source and the replacement before modifying the class.
    3. It creates a function from the candidate method's code with the installed original method's globals, then assigns that function to IotDevice._modular_update. This preserves the installed module's HomeKit class, merge helper, and logger. The functional change is the PR's six added lines: HomeKit gets its own request instead of being batched after system. HomeKit querying is retained, rather than disabled.
    4. Loaded the component with one top-level YAML stanza and restarted HA. Installed python-kasa package files, HA's built-in TP-Link integration, plug firmware, cloud pairing, and firewall settings were not changed.

    The core assignment is:

    replacement = FunctionType(
        candidate_method.__code__,
        original_method.__globals__,
        original_method.__name__,
        original_method.__defaults__,
        original_method.__closure__,
    )
    IotDevice._modular_update = replacement

    This is a locally constructed temporary loader for testing/backporting the upstream production change, not an installation mechanism supplied or endorsed by the PR author. I tested its idempotence, refusal to patch unexpected original source, and skip behavior on a different library version. It does not rewrite installed library files; on a library-version change it becomes inactive and can be removed after verifying the official fix. A version change alone is not proof the fix is included.

    Scope: two physical EP10s, repeated read updates, and HA service-to-real-relay control. I did not run the full upstream test suite or test a HomeKit-capable device, and this is immediate post-restart verification rather than a long-term soak test. No firmware upgrade or Home Assistant rollback was needed.

  5. frogen1 commented on Oct 15, 2026

    Confirming on HS103 (US), hardware 5.0, firmware 1.0.3 Build 201015 Rel.142523 (5 plugs): HA 2026.10.1 / python-kasa 0.11.0.1 times out; HA 2026.10.0 / python-kasa 0.10.2 works. Also reported downstream at home-assistant/core#185859.

    Reproduced the ordering finding with raw XOR requests (no python-kasa), and compared against the same hardware on newer firmware:

    Request HS103 hw 5.0, fw 1.0.3 HS103 hw 5.0, fw 1.0.13 Build 240117
    system.get_sysinfo only OK (85 ms) OK (10 ms)
    system, then smartlife.iot.homekit.setup_info_get no response, 7 s timeout OK (12 ms)
    homekit, then system OK (56 ms); homekit returns -1 "module not support" OK (10 ms)

    fw 1.0.13 on the same hardware handles either order; the hang appears specific to fw 1.0.3.

    Tested #1792 (commit ee5061e) with python -m kasa.cli --host <ip> --type plug state (Python 3.14, Windows): published 0.11.0.1 times out (~24 s with retries); commit ee5061e returns full state in ~0.8–1.0 s on all 5 HS103 fw 1.0.3 plugs and still works on the HS103 fw 1.0.13.

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