FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Discovery: accept cameras that only send the encrypt_type list by freeKC · Pull Request #1770 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions kasa/discover.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ def _get_connection_parameters(
# Reuse the login_version attribute to pass the max to transport
login_version = max([int(i) for i in et])

if not encrypt_type and encrypt_schm.is_support_https and login_version == 3:
# Some camera firmwares (C460 1.2.2 for one) leave encrypt_type out
# of mgt_encrypt_schm and send no encrypt_info, only the top level
# encrypt_type list. "3" is the AES login that every other camera
# reports as sym_schm AES.
encrypt_type = DeviceEncryptionType.Aes.value

if not encrypt_type:
raise UnsupportedDeviceError(
f"Unsupported device {discovery_result.ip} of type {type_} "
Expand Down
28 changes: 28 additions & 0 deletions tests/test_discovery.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
from kasa.deviceconfig import (
DeviceConfig,
DeviceConnectionParameters,
DeviceEncryptionType,
DeviceFamily,
)
from kasa.discover import (
DiscoveryResult,
Expand Down Expand Up @@ -749,3 +751,29 @@ async def test_discovery_device_repr(discovery_mock, mocker):
assert "update() needed" not in repr_
else:
assert "update() needed" in repr_


async def test_connection_parameters_from_encrypt_type_list_only():
"""Cameras that send only the encrypt_type list are treated as AES login."""
result = {
"device_type": "SMART.IPCAMERA",
"device_model": "C460",
"device_id": "0000000000000000000000000000000000000000",
"ip": "127.0.0.123",
"mac": "7C-F1-7E-00-00-00",
"mgt_encrypt_schm": {"is_support_https": True},
"encrypt_type": ["3"],
"firmware_version": "1.2.2 Build 260416 Rel.13928n",
"hardware_version": "1.0",
}
params = Discover._get_connection_parameters(DiscoveryResult.from_dict(result))

assert params.device_family is DeviceFamily.SmartIpCamera
assert params.encryption_type is DeviceEncryptionType.Aes
assert params.login_version == 3
assert params.https is True

# Without the "3" hint the device is still reported as unsupported
result["encrypt_type"] = ["9"]
with pytest.raises(UnsupportedDeviceError, match="no encryption type"):
Discover._get_connection_parameters(DiscoveryResult.from_dict(result))
Loading

Back | FazBrowse Home | New Git URL