mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-11-07 12:27:19 +00:00
Use clearer error message for unsupported encryption types (#1831)
Some checks failed
CI / Perform Lint Checks (3.15) (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.15 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.15 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
CI / Python 3.15 on windows-latest (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
Stale / stale (push) Has been cancelled
Some checks failed
CI / Perform Lint Checks (3.15) (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.15 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.15 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
CI / Python 3.15 on windows-latest (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
Stale / stale (push) Has been cancelled
Devices that announce an encryption type the library does not know, such as `TPAP` used by newer Tapo devices (e.g. RV20 Max Plus), previously failed with a generic message that dumped the whole encryption scheme: ``` Unsupported device 192.168.xx.xx of type SMART.TAPOROBOVAC with encrypt_scheme EncryptionScheme(is_support_https=True, encrypt_type='TPAP', http_port=4433, lv=2) ``` This can be rather confusing to interpret, as it does not tell what is not supported (e.g., the device type is definitely supported on non-tpap transports). This PR adds a separate check and error message for cases where the encryption type is not supported, giving this error: ``` Device 192.168.xx.xx (SMART.TAPOROBOVAC) uses unsupported encryption type TPAP ```
This commit is contained in:
@@ -845,6 +845,14 @@ class Discover:
|
||||
discovery_result=discovery_result.to_dict(),
|
||||
host=discovery_result.ip,
|
||||
)
|
||||
|
||||
if encrypt_type not in {e.value for e in DeviceEncryptionType}:
|
||||
raise UnsupportedDeviceError(
|
||||
f"Device {discovery_result.ip} ({type_}) uses unsupported "
|
||||
f"encryption type {encrypt_type}",
|
||||
discovery_result=discovery_result.to_dict(),
|
||||
host=discovery_result.ip,
|
||||
)
|
||||
return DeviceConnectionParameters.from_values(
|
||||
type_,
|
||||
encrypt_type,
|
||||
|
||||
Reference in New Issue
Block a user