Skip to content

Fix HS300 KLAP v2 direct connect#1676

Closed
jazvw wants to merge 2 commits intopython-kasa:masterfrom
jazvw:fix-hs300-klap-v2-direct-connect
Closed

Fix HS300 KLAP v2 direct connect#1676
jazvw wants to merge 2 commits intopython-kasa:masterfrom
jazvw:fix-hs300-klap-v2-direct-connect

Conversation

@jazvw
Copy link
Copy Markdown

@jazvw jazvw commented Mar 20, 2026

Summary

This fixes direct connection for HS300 devices that report IOT.SMARTPLUGSWITCH with KLAP and login_version=2.

Changes:

  • select KlapTransportV2 for IOT.KLAP devices when login_version == 2
  • use get_sysinfo-based class detection for IOT direct-connect transports beyond XOR, so HS300 is created as IotStrip instead of IotPlug
  • add focused coverage for the HS300 KLAP v2 direct-connect path

Testing

Fixture-backed:

  • ./.venv/bin/python -m pytest -q tests/test_hs300_klap_lv2.py -k strip_fixture

Real hardware:

  • ./.venv/bin/python -m pytest -q tests/test_hs300_klap_lv2.py --ip=<hs300-ip> -k real_device

Additional targeted coverage:

  • ./.venv/bin/python -m pytest -q -o addopts= tests/test_device_factory.py -k test_get_protocol

Notes

I was able to verify this against an HS300 that uses KLAP with login_version=2.

I could not test this against older HS300 variants that still use the older direct-connect path, since I do not have access to those devices.

I used Codex CLI to help trace the failure, inspect the local git history, and narrow the fix to the HS300 KLAP v2 direct-connect path.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.22%. Comparing base (be5ce08) to head (22269dc).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1676   +/-   ##
=======================================
  Coverage   93.22%   93.22%           
=======================================
  Files         157      157           
  Lines        9815     9818    +3     
  Branches     1003     1004    +1     
=======================================
+ Hits         9150     9153    +3     
  Misses        472      472           
  Partials      193      193           

☔ View full report in Codecov by Sentry.
📢 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.

@ZeliardM
Copy link
Copy Markdown
Contributor

@jazvw There is already an existing PR #1580 that resolves this issue and others with the CLI that occur when making changes with the device handling. Please close this out and wait for that one to be merged. Thanks!

@jazvw
Copy link
Copy Markdown
Author

jazvw commented Mar 20, 2026

Ok, thanks!

@jazvw jazvw closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants