fix: use KLAP v2 transport for IOT devices with login version 2 (#1731)
Some checks failed
CI / Perform Lint Checks (3.14) (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled

Some IOT-family devices keep the legacy IOT command set after a firmware
update but upgrade their KLAP authentication to login version 2 (sha256 hashing).

This change selects `KlapTransportV2` for `IOT.KLAP` devices that advertise
`login_version >= 2`, matching the transport already used for `SMART.KLAP`.
Devices with login version 1 (or unset) are unchanged and continue to use the v1 `KlapTransport`.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Brian Marks
2026-09-30 13:33:30 -04:00
committed by GitHub
parent 9d84bb74e7
commit 998ebe79e8
2 changed files with 18 additions and 0 deletions

View File

@@ -239,4 +239,10 @@ def get_protocol(config: DeviceConfig, *, strict: bool = False) -> BaseProtocol
if not (prot_tran_cls := supported_device_protocols.get(protocol_transport_key)):
return None
protocol_cls, transport_cls = prot_tran_cls
if (
protocol_transport_key == "IOT.KLAP"
and ctype.login_version
and ctype.login_version >= 2
):
transport_cls = KlapTransportV2
return protocol_cls(transport=transport_cls(config=config))

View File

@@ -259,6 +259,18 @@ ET = DeviceEncryptionType
KlapTransport,
id="iot-klap",
),
pytest.param(
CP(DF.IotSmartPlugSwitch, ET.Klap, login_version=1, https=False),
IotProtocol,
KlapTransport,
id="iot-klap-v1",
),
pytest.param(
CP(DF.IotSmartPlugSwitch, ET.Klap, login_version=2, https=False),
IotProtocol,
KlapTransportV2,
id="iot-klap-v2",
),
pytest.param(
CP(DF.IotSmartPlugSwitch, ET.Xor, https=False),
IotProtocol,