Add smartcamera devices to supported docs (#1257)

The library now officially supports H200, C200 and TC65
This commit is contained in:
Steven B.
2024-11-14 18:28:30 +00:00
committed by GitHub
parent b8f6651d9b
commit 5fe75cada9
6 changed files with 89 additions and 10 deletions

View File

@@ -46,6 +46,7 @@ from kasa.protocols.smartcameraprotocol import (
)
from kasa.protocols.smartprotocol import SmartProtocol, _ChildProtocolWrapper
from kasa.smart import SmartChildDevice
from kasa.smartcamera import SmartCamera
Call = namedtuple("Call", "module method")
FixtureResult = namedtuple("FixtureResult", "filename, folder, data")
@@ -973,14 +974,12 @@ async def get_smart_fixtures(
copy_folder = SMART_FOLDER
else:
# smart camera protocol
basic_info = final["getDeviceInfo"]["device_info"]["basic_info"]
hw_version = basic_info["hw_version"]
sw_version = basic_info["sw_version"]
model = basic_info["device_model"]
region = basic_info.get("region")
sw_version = sw_version.split(" ", maxsplit=1)[0]
if region is not None:
model = f"{model}({region})"
model_info = SmartCamera._get_device_info(final, discovery_info)
model = model_info.long_name
hw_version = model_info.hardware_version
sw_version = model_info.firmare_version
if model_info.region is not None:
model = f"{model}({model_info.region})"
copy_folder = SMARTCAMERA_FOLDER
save_filename = f"{model}_{hw_version}_{sw_version}.json"

View File

@@ -10,7 +10,8 @@ from typing import NamedTuple
from kasa.device_factory import _get_device_type_from_sys_info
from kasa.device_type import DeviceType
from kasa.smart.smartdevice import SmartDevice
from kasa.smart import SmartDevice
from kasa.smartcamera import SmartCamera
class SupportedVersion(NamedTuple):
@@ -32,6 +33,7 @@ DEVICE_TYPE_TO_PRODUCT_GROUP = {
DeviceType.Fan: "Wall Switches",
DeviceType.Bulb: "Bulbs",
DeviceType.LightStrip: "Light Strips",
DeviceType.Camera: "Cameras",
DeviceType.Hub: "Hubs",
DeviceType.Sensor: "Hub-Connected Devices",
DeviceType.Thermostat: "Hub-Connected Devices",
@@ -43,6 +45,7 @@ README_FILENAME = "README.md"
IOT_FOLDER = "tests/fixtures/"
SMART_FOLDER = "tests/fixtures/smart/"
SMARTCAMERA_FOLDER = "tests/fixtures/smartcamera/"
def generate_supported(args):
@@ -58,6 +61,7 @@ def generate_supported(args):
_get_iot_supported(supported)
_get_smart_supported(supported)
_get_smartcamera_supported(supported)
readme_updated = _update_supported_file(
README_FILENAME, _supported_summary(supported), print_diffs
@@ -234,6 +238,29 @@ def _get_smart_supported(supported):
)
def _get_smartcamera_supported(supported):
for file in Path(SMARTCAMERA_FOLDER).glob("**/*.json"):
with file.open() as f:
fixture_data = json.load(f)
model_info = SmartCamera._get_device_info(
fixture_data, fixture_data.get("discovery_result")
)
supported_type = DEVICE_TYPE_TO_PRODUCT_GROUP[model_info.device_type]
stype = supported[model_info.brand].setdefault(supported_type, {})
smodel = stype.setdefault(model_info.long_name, [])
smodel.append(
SupportedVersion(
region=model_info.region,
hw=model_info.hardware_version,
fw=model_info.firmare_version,
auth=model_info.requires_auth,
)
)
def _get_iot_supported(supported):
for file in Path(IOT_FOLDER).glob("*.json"):
with file.open() as f: