Make uses_http a readonly property of device config (#1449)

`uses_http` will no longer be included in `DeviceConfig.to_dict()`
This commit is contained in:
Steven B.
2025-01-14 14:20:53 +00:00
committed by GitHub
parent 57f6c4138a
commit be34dbd387
7 changed files with 25 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ from typing import Any
from .device import Device
from .device_type import DeviceType
from .deviceconfig import DeviceConfig, DeviceFamily
from .deviceconfig import DeviceConfig, DeviceEncryptionType, DeviceFamily
from .exceptions import KasaException, UnsupportedDeviceError
from .iot import (
IotBulb,
@@ -176,25 +176,32 @@ def get_device_class_from_family(
return cls
def get_protocol(
config: DeviceConfig,
) -> BaseProtocol | None:
"""Return the protocol from the connection name.
def get_protocol(config: DeviceConfig, *, strict: bool = False) -> BaseProtocol | None:
"""Return the protocol from the device config.
For cameras and vacuums the device family is a simple mapping to
the protocol/transport. For other device types the transport varies
based on the discovery information.
:param config: Device config to derive protocol
:param strict: Require exact match on encrypt type
"""
ctype = config.connection_type
protocol_name = ctype.device_family.value.split(".")[0]
if ctype.device_family is DeviceFamily.SmartIpCamera:
if strict and ctype.encryption_type is not DeviceEncryptionType.Aes:
return None
return SmartCamProtocol(transport=SslAesTransport(config=config))
if ctype.device_family is DeviceFamily.IotIpCamera:
if strict and ctype.encryption_type is not DeviceEncryptionType.Xor:
return None
return IotProtocol(transport=LinkieTransportV2(config=config))
if ctype.device_family is DeviceFamily.SmartTapoRobovac:
if strict and ctype.encryption_type is not DeviceEncryptionType.Aes:
return None
return SmartProtocol(transport=SslTransport(config=config))
protocol_transport_key = (