mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-10-16 17:44:17 +00:00
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 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:
@@ -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)):
|
if not (prot_tran_cls := supported_device_protocols.get(protocol_transport_key)):
|
||||||
return None
|
return None
|
||||||
protocol_cls, transport_cls = prot_tran_cls
|
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))
|
return protocol_cls(transport=transport_cls(config=config))
|
||||||
|
|||||||
@@ -259,6 +259,18 @@ ET = DeviceEncryptionType
|
|||||||
KlapTransport,
|
KlapTransport,
|
||||||
id="iot-klap",
|
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(
|
pytest.param(
|
||||||
CP(DF.IotSmartPlugSwitch, ET.Xor, https=False),
|
CP(DF.IotSmartPlugSwitch, ET.Xor, https=False),
|
||||||
IotProtocol,
|
IotProtocol,
|
||||||
|
|||||||
Reference in New Issue
Block a user