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 — feat(klaptransport): auto-detect KLAP v2 for IOT devices by adamjacobmuller · Pull Request #1625 · python-kasa/python-kasa

Conversation

@adamjacobmuller

@adamjacobmuller adamjacobmuller commented Dec 27, 2025

Copy link
Copy Markdown

Summary

Some IOT devices (e.g., HS300 with newer firmware) use KLAP v2 authentication (sha256/sha1 hashing) despite being classified as IOT devices. Previously, IOT.KLAP was hardcoded to use KlapTransport which only supports v1 (md5) hashing, causing authentication failures with the error:

Device response did not match our challenge on ip X.X.X.X, check that your e-mail and password (both case-sensitive) are correct.

Changes

This PR modifies KlapTransport.perform_handshake1() to try v2 hashing (sha256/sha1) as a fallback when v1 (md5) doesn't match the server hash. If v2 succeeds, the transport remembers this via _uses_v2_hashing flag and uses v2 hashing for handshake2 as well.

The v2 fallback tries:

  1. User credentials with v2 hashing
  2. Default credentials with v2 hashing
  3. Blank credentials with v2 hashing

Affected devices

  • HS300 power strip (and potentially other IOT devices with updated firmware)

Testing

Tested on HS300 that was previously failing authentication. After this change, the device authenticates successfully using KLAP v2 while still being correctly classified as an IOT device.

Sorry, something went wrong.

Uh oh!

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

All reactions
Adam Jacob Muller
feat(klaptransport): auto-detect KLAP v2 for IOT devices
dd92c05
Some IOT devices (e.g., HS300 with newer firmware) use KLAP v2
authentication (sha256/sha1 hashing) despite being classified as
IOT devices. This modifies KlapTransport to try v2 hashing as a
fallback when v1 doesn't match.
@ZeliardM

ZeliardM commented Dec 27, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Collaborator

@adamjacobmuller Appreciate the great work here. The newer firmwares have a new flag in the device discovery process called new_klap. I created a PR already that uses this flag to determine the correct transport to use during the discovery process instead of modifying the transports themselves, PR#1580.

Your method, while it works, mixes the authentication process between the two different KLAP transports and it doesn't keep a clean line of separation between them.

I just finished it recently, had to handle some issues with the CLI and making sure that all of the other devices and tests worked correctly. Just waiting on merging and a new version to get it going.

All reactions

Sorry, something went wrong.

Uh oh!

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

@wheel5up wheel5up mentioned this pull request Jan 5, 2026
KLAP v2 Authentication Failure on TP-Link HS300 (US) — Hardware Version 2.0 #1604
Open
@danielbrodie

danielbrodie commented Jan 23, 2026

Copy link
Copy Markdown

Confirmed Working ✅

Just tested this PR on two HS300 power strips that were previously failing with the "Device response did not match our challenge" error.

Environment:

  • HS300 (US) Hardware v2.0
  • Firmware 1.1.2 Build 241220
  • macOS / Python 3.14

Before this PR: Authentication failed with KLAP v1 (md5)
After this PR: Both strips connect and all 12 outlets are controllable

Test Results:

192.168.0.120: ✓ SUCCESS! TP-LINK_Power Strip_1C73 (HS300)
  Outlets: Coffee Maker, Kettle, Milk Frother, Roku TV, Apple Player, Rice Cooker

192.168.0.219: ✓ SUCCESS! TP-LINK_Power Strip_1CD6 (HS300)
  Outlets: Tripod Lamp, Plug 2-6

The auto-detection of KLAP v2 worked seamlessly. Really appreciate this fix - these strips have been unusable with Home Assistant since the October firmware update.

Hope this helps get the PR merged! 🎉

All reactions

Sorry, something went wrong.

Uh oh!

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

@adamjacobmuller

adamjacobmuller commented Jan 23, 2026

Copy link
Copy Markdown
Author

HS300 was exactly what I built this for (nice little gadget). Hoping it gets merged too, but, it works fine for me either way :)

All reactions

Sorry, something went wrong.

Uh oh!

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

@2myaus

2myaus commented Apr 15, 2026

Copy link
Copy Markdown

This doesn't seem working for my HS300s; connection succeeds, but the device class is wrongly set as kasa.iot.iotplug.IotPlug instead of kasa.iot.iotstrip.IotStrip. Because of this, I'm unable to control sockets on the power strip from a script (device.children is an empty list)

model: HS300(US)
build: 241220
on nixOS linux with Python 3.13.12

My test script:

import asyncio
import kasa

async def main():
    dev = await kasa.Device.connect(
        config=kasa.DeviceConfig(
            host=input("host? "),
            credentials=kasa.Credentials(
                username="[email protected]",
                password="xxx",
            ),
            connection_type=kasa.DeviceConnectionParameters(
                device_family=kasa.DeviceFamily.IotSmartPlugSwitch,
                encryption_type=kasa.DeviceEncryptionType.Klap,
            ),
        )
    )
    await dev.update()
    print(f"children: {dev.children}")
    await dev.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

Please let me know if I can provide any more information or am doing something wrong; I'm not very familiar with python-kasa and am just looking to get this working for a larger project.

I've created a fork that patches the issue for me by detecting device type through sys_info for KLAP connections (where this was only previously done on connections using the XOR transport). I don't expect this to be an accepted solution, but it solved the issue for me and may be of some use:
adamjacobmuller@97cdd71

All reactions

Sorry, something went wrong.

Uh oh!

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

@thatdaveguy1 thatdaveguy1 mentioned this pull request Apr 18, 2026
IOT KLAP devices can be misclassified as IotPlug (missing children) #1691
Closed
@bradcarnage

bradcarnage commented May 25, 2026

Copy link
Copy Markdown

Hey @adamjacobmuller — appreciate the work here, this was one of the first PRs to tackle the IOT KLAPv2 auth issue and confirmed it's a real problem affecting many users. 🙏

That said, #1692 takes a cleaner approach — it selects upfront in based on rather than falling back at runtime inside the handshake. This avoids mixing v1/v2 auth logic inside and keeps the transport boundary clean (as @ZeliardM also noted).

#1692 also fixes the device class misdetection that @2myaus reported here — HS300 strips wrongly instantiated as with empty . That fix requires the sysinfo query path change in which this PR doesn't cover.

Would you be open to closing this in favor of #1692? Both solve the core auth problem, but 1692 handles the broader set of regressions with tests included. 🤝

All reactions

Sorry, something went wrong.

Uh oh!

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

@bradcarnage bradcarnage mentioned this pull request May 25, 2026
Unable to authenticate: Device response did not match our challenge on ip 192.xxx.x.xxx, check that your e-mail and password (both case-sensitive) are correct home-assistant/core#164777
Closed
@ZeliardM

ZeliardM commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

There is already an existing, extensively tested PR that handles all of the CLI and API changes, #1580, we are working to get this implemented and a new version released soon.

All reactions

Sorry, something went wrong.

Uh oh!

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

@thehcma thehcma mentioned this pull request Jul 10, 2026
chore: revert python-kasa git pin to PyPI the-hcma/domesti-bot#433
Closed
5 tasks done
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale label Oct 8, 2026
@github-actions github-actions Bot closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

stale

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

5 participants

@adamjacobmuller @ZeliardM @danielbrodie @2myaus @bradcarnage
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.