GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: query IoT HomeKit separately to avoid legacy device timeouts by cheeseandcereal · Pull Request #1792 · python-kasa/python-kasa

Conversation

@cheeseandcereal

@cheeseandcereal cheeseandcereal commented Oct 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

Send the IoT HomeKit query in its own request. Some legacy firmware times out when an unsupported smartlife.iot.homekit.setup_info_get query follows another module in a batch, preventing the entire device update from completing.

Fixes: #1791
Fixes: #1788

I've tested this fix on devices EP10, HS103 and KP115. A closely matching downstream report is home-assistant/core#185859.

Root cause

On the same devices and network path, python-kasa 0.10.2 completes initial and subsequent updates, while 0.11.0.1 times out. The probe was introduced in #1566.

This minimal request times out while waiting for the response header:

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

Reversing the two module keys succeeds. Sending HomeKit alone also succeeds and returns:

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

This ordering behavior was reproduced on EP10(US) hardware 1.0 / firmware 1.0.2, HS103(US) hardware 5.0 / firmware 1.0.3, and KP115(US) hardware 1.0 / firmware 1.0.7. Full firmware build identifiers are in #1791.

Implementation

Keep HomeKit out of the normal modular-update batch and merge its response through the existing update path. Unsupported responses are cached by the existing module support detection, so subsequent updates omit the query. Supported HomeKit remains available. Genuine communication failures and cancellation still propagate.

The production change is six lines and avoids relying on JSON key ordering or model/firmware lists. Unsupported devices incur one additional request during initialization; supported devices query HomeKit separately during updates.

Validation

  • All seven tested plugs fail with published 0.11.0.1 and complete two updates with this patch: four HS103, two EP10 and one KP115.
  • One representative of each model completes two updates with published 0.10.2 and with a diagnostic standalone HomeKit probe on 0.11.0.1.
  • Patched EP10, HS103 and KP115 also pass on Python 3.14.8 with speedups, default retries and a disconnect between updates. KP115 energy readings remain available.
  • Regression tests simulate the measured firmware behavior and cover discovery-seeded/cold initialization, repeated updates, unsupported detection, supported EP25 HomeKit data, energy availability, strip-parent handling, timeouts, cancellation and recovery. The EP10 regression fails against unpatched production code.
  • uv run pytest -q -n 8 --timeout=30 --tb=short --maxfail=5: 23795 passed, 901 skipped.
  • uv run pre-commit run --files kasa/iot/iotdevice.py tests/iot/modules/test_homekit.py tests/iot/test_iotdevice.py: all applicable checks pass, including mypy.
  • git diff --check: passes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasoncodes, AlecRust, and databoy2k reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
@cheeseandcereal
fix: query IoT HomeKit separately to avoid legacy device timeouts
ee5061e
@codecov

codecov Bot commented Oct 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (38a3184) to head (ee5061e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1792      +/-   ##
==========================================
+ Coverage   93.41%   93.45%   +0.04%     
==========================================
  Files         159      159              
  Lines       10113    10116       +3     
  Branches     1043     1044       +1     
==========================================
+ Hits         9447     9454       +7     
+ Misses        472      470       -2     
+ Partials      194      192       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cheeseandcereal cheeseandcereal mentioned this pull request Oct 11, 2026
TP-Link HS103 issues home-assistant/core#185859
Closed
@igiannakas

igiannakas commented Oct 13, 2026

Copy link
Copy Markdown

Confirming this on HS110(UK) hw 4.1, fw 1.1.1 Build 201203 Rel.135822, the same model and firmware as #1788. I'm on HA 2026.10.1 with python-kasa 0.11.0.1. Discovery works, but the first update() times out three times on port 9999 and the config flow fails. An HS100(UK) hw 2.1 on fw 1.5.10 on the same network works normally.

I sent raw XOR requests directly to the plug, opening a new connection for each, with a 6 s timeout:

Request Result
system.get_sysinfo only OK, 0.03 s
smartlife.iot.homekit.setup_info_get only OK, 0.11 s, {"err_code":-1,"err_msg":"module not support"}
system + homekit Timeout
homekit + system OK, 0.02 s
system + foo.bar (made-up module) Timeout
system + emeter + homekit OK, 0.05 s, homekit returns module not support
emeter + homekit OK, 0.03 s
Full 0.11.0.1 first-update query Timeout
Same query with homekit removed OK, 0.06 s

This firmware matches @ewalker101's finding: it hangs whenever an unsupported module comes directly after system. HomeKit sent on its own returns the unsupported error cleanly, and the rest of the batch works without it, so the #1792 approach should work for this device. Because foo.bar after system also hangs, it may be worth covering that general case too, so a future module doesn't reintroduce the bug.

I haven't run the #1792 branch yet. I'm happy to test it if that helps.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@psiberfunk psiberfunk mentioned this pull request Oct 15, 2026
IoT HomeKit query ordering causes update timeouts for legacy devices in 0.11.0.1 #1791
Closed
@psiberfunk

psiberfunk commented Oct 15, 2026

Copy link
Copy Markdown

Confirmed the production change in this PR (ee5061e37ccad6bd95cd2cacaa812a9db773817f) restores two EP10(US), hardware 1.0, firmware 1.0.2 Build 200915 Rel.085940 plugs, both in an isolated macOS/Python 3.14 test and in Home Assistant OS 18.3 / Core 2026.10.1.

  • Published python-kasa==0.11.0.1: initial update times out on both physical plugs.
  • Exact candidate _modular_update method applied in memory: both complete two consecutive status updates, disconnecting between updates (approximately 0.12–0.27 seconds/update).
  • Same replacement loaded inside HA using a temporary startup custom component: after restart, both config entries are loaded and both switch entities recover.
  • HA switch.turn_on / switch.turn_off succeeds on both plugs. Independent direct get_sysinfo reads verify the real relays report 1 then 0; HA state publication settles in roughly one second. Both restored to their initial off state.

The temporary loader checks the exact library version and original/replacement source fingerprints, then constructs the replacement with FunctionType(candidate.__code__, original.__globals__, ...) and assigns it to IotDevice._modular_update. It uses the PR's unchanged method, retaining HomeKit queries as separate requests; it does not use the workaround that disables the HomeKit module. No installed library files, device firmware, cloud pairing, or firewall settings were changed, and no HA rollback was needed.

Full test results, installation method, guards, and limitations.

This confirms the PR's production change via a locally constructed runtime backport, rather than installing/testing the entire candidate package. I did not run the full upstream suite or test a HomeKit-capable device. This is immediate post-restart verification, not a long-term soak test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bmhughes bmhughes mentioned this pull request Oct 16, 2026
TP-Link KP-100 Smart Plug Loses Connection after Core Update to 2026.10.1 home-assistant/core#185971
Closed
This was referenced Oct 17, 2026
HS110(UK) v4.1 beta firmware times out with the HomeKit probe in 0.11.0.1 #1788
Closed
Regression in python-kasa 0.11.0.1: KP100(US) Times Out on Combined IoT Requests (Works in 0.10.2) #1799
Closed
EP10 (fw 1.0.2 Build 200915) times out on update() with 0.11.0.1; raw get_sysinfo works home-assistant/core#185900
Closed
@psiberfunk

psiberfunk commented Oct 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

For review: HS110(UK) hw 4.1 / fw 1.1.1 Build 201203 Rel.135822 is now confirmed too. That's the beta-firmware model from #1788, and the one gap #1791 called out. @AlecRust ran ee5061e on all three of their plugs: updates work, including after reconnecting, and energy readings are intact (comment on #1788).

So this commit now has real-hardware passes on EP10, HS103, KP115 and HS110(UK). KP100 (#1799) and HS200 (#1803) show the same failure signature but haven't been run against it yet.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BluThunder2k

BluThunder2k commented Oct 18, 2026

Copy link
Copy Markdown

Another confirmation matching #1803:

  • HS200(US), hardware 5.0
  • Firmware 1.0.2 Build 200819 Rel.105309
  • HA Core upgraded from 2026.9.3 to 2026.10.2
  • python-kasa 0.11.0.1

The switch stopped initializing after the upgrade. Power cycling the switch and restarting HA did not help. The Kasa app still controlled it locally with internet access blocked.

HA debug logs showed standalone system.get_sysinfo succeeding in about 0.11 seconds. The combined initialization query, with smartlife.iot.homekit.setup_info_get immediately after system, repeatedly timed out waiting for the response header.

A version-guarded custom component making HomeKit.query() return {} restored initialization and normal switching from HA after a restart.

To clarify, this validates the probe-suppression workaround, not this PR’s separate-request implementation. Thanks for working on the long term fix!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coffeeandubuntu

coffeeandubuntu commented Oct 19, 2026

Copy link
Copy Markdown

Tested PR #1792 against TP-Link KP100(US), hardware v3.0, firmware 1.0.1 Build 200831 Rel.142128.

Results:
python-kasa 0.10.2: Previously confirmed working.
python-kasa 0.11.0.1: Timeout during state query.

PR #1792 (ee5061e): Successfully retrieves device state.
Multiple consecutive state queries: Successful.

This confirms the proposed fix resolves the regression on KP100(US) hardware v3.0.

Thank you for working on this!

truncj and databoy2k reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@databoy2k

databoy2k commented Oct 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Another affected device, and it's a dimmer: HS220(US) hw 2.0, fw 1.0.4 Build 200907, python-kasa 0.11.0.1 (Home Assistant 2026.10.2). Same symptom as #1791: the first update times out, TCP connects, and every module answers fine on its own.

I haven't seen dimmers among the tested devices so far, and they add something relevant here: IotDimmer also registers the probe-only PIR and LAS modules (both reply module not support at module level on this device).

Raw TCP results, keys in the order sent:

Request Result
system, homekit times out
homekit, system OK
system, PIR / system, LAS times out
full python-kasa request times out (0/5)
full request without homekit (PIR and LAS still in it, not adjacent to system) OK, 5/5
system, schedule, homekit OK
system, schedule, time, cnCloud, dimmer, homekit, PIR, LAS times out

Reading the diff, only HomeKit is moved into its own request, so on this dimmer the requests should be homekit alone, then system, schedule, anti_theft, time, cnCloud, PIR, LAS, dimmer. Both of those passed on this device (the second 5/5). I haven't run the PR itself on it.

Two observations that may matter for the fix. PIR and LAS aren't special-cased, so they avoid hanging here only because other modules sit between them and system. And the last row hangs even though nothing unsupported is adjacent to system, so "an unsupported module directly after system" doesn't look like the whole rule on this firmware. I can test this branch on the switch if useful.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rytilahti rytilahti mentioned this pull request Oct 24, 2026
Add Device.supports_module() and stop querying HomeKit for iot devices #1808
Merged
rytilahti
rytilahti reviewed Oct 24, 2026
View reviewed changes

@rytilahti rytilahti left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cheeseandcereal and thanks for the PR! I have been trying to find out a way to avoid the issue described in the linked issues while keeping the door open for any similar issues in the future. I created a pull request (#1808) to replace this one, please take a look and let me know what do you think of this approach.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cheeseandcereal

cheeseandcereal commented Oct 25, 2026

Copy link
Copy Markdown
Author

Ah, thanks for taking a look @rytilahti

Yeah, I think you're approach is much better for the future when more modules will inevitably be added :)

Will close this one/defer to that. Thanks!

rytilahti reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cheeseandcereal cheeseandcereal closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rytilahti rytilahti rytilahti left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

IoT HomeKit query ordering causes update timeouts for legacy devices in 0.11.0.1 HS110(UK) v4.1 beta firmware times out with the HomeKit probe in 0.11.0.1

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@cheeseandcereal @igiannakas @psiberfunk @BluThunder2k @coffeeandubuntu @databoy2k @rytilahti
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.