Skip to content

Conversation

@adamjacobmuller
Copy link

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.

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
Copy link
Contributor

ZeliardM commented Dec 27, 2025

@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.

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