mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-04 09:44:14 +00:00
Rename smartcamera to smartcam (#1300)
This commit is contained in:
@@ -25,7 +25,7 @@ from typing import Any
|
||||
|
||||
import asyncclick as click
|
||||
|
||||
from devtools.helpers.smartcamerarequests import SMARTCAMERA_REQUESTS
|
||||
from devtools.helpers.smartcamrequests import SMARTCAM_REQUESTS
|
||||
from devtools.helpers.smartrequests import SmartRequest, get_component_requests
|
||||
from kasa import (
|
||||
AuthenticationError,
|
||||
@@ -42,19 +42,19 @@ from kasa.deviceconfig import DeviceEncryptionType, DeviceFamily
|
||||
from kasa.discover import DiscoveryResult
|
||||
from kasa.exceptions import SmartErrorCode
|
||||
from kasa.protocols import IotProtocol
|
||||
from kasa.protocols.smartcameraprotocol import (
|
||||
SmartCameraProtocol,
|
||||
from kasa.protocols.smartcamprotocol import (
|
||||
SmartCamProtocol,
|
||||
_ChildCameraProtocolWrapper,
|
||||
)
|
||||
from kasa.protocols.smartprotocol import SmartProtocol, _ChildProtocolWrapper
|
||||
from kasa.smart import SmartChildDevice, SmartDevice
|
||||
from kasa.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
Call = namedtuple("Call", "module method")
|
||||
FixtureResult = namedtuple("FixtureResult", "filename, folder, data")
|
||||
|
||||
SMART_FOLDER = "tests/fixtures/smart/"
|
||||
SMARTCAMERA_FOLDER = "tests/fixtures/smartcamera/"
|
||||
SMARTCAM_FOLDER = "tests/fixtures/smartcam/"
|
||||
SMART_CHILD_FOLDER = "tests/fixtures/smart/child/"
|
||||
IOT_FOLDER = "tests/fixtures/iot/"
|
||||
|
||||
@@ -65,7 +65,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@dataclasses.dataclass
|
||||
class SmartCall:
|
||||
"""Class for smart and smartcamera calls."""
|
||||
"""Class for smart and smartcam calls."""
|
||||
|
||||
module: str
|
||||
request: dict
|
||||
@@ -562,7 +562,7 @@ async def _make_requests_or_exit(
|
||||
# Calling close on child protocol wrappers is a noop
|
||||
protocol_to_close = protocol
|
||||
if child_device_id:
|
||||
if isinstance(protocol, SmartCameraProtocol):
|
||||
if isinstance(protocol, SmartCamProtocol):
|
||||
protocol = _ChildCameraProtocolWrapper(child_device_id, protocol)
|
||||
else:
|
||||
protocol = _ChildProtocolWrapper(child_device_id, protocol)
|
||||
@@ -608,7 +608,7 @@ async def get_smart_camera_test_calls(protocol: SmartProtocol):
|
||||
successes: list[SmartCall] = []
|
||||
|
||||
test_calls = []
|
||||
for request in SMARTCAMERA_REQUESTS:
|
||||
for request in SMARTCAM_REQUESTS:
|
||||
method = next(iter(request))
|
||||
if method == "get":
|
||||
module = method + "_" + next(iter(request[method]))
|
||||
@@ -693,7 +693,7 @@ async def get_smart_camera_test_calls(protocol: SmartProtocol):
|
||||
click.echo(f"Skipping {component_id}..", nl=False)
|
||||
click.echo(click.style("UNSUPPORTED", fg="yellow"))
|
||||
else: # Not a smart protocol device so assume camera protocol
|
||||
for request in SMARTCAMERA_REQUESTS:
|
||||
for request in SMARTCAM_REQUESTS:
|
||||
method = next(iter(request))
|
||||
if method == "get":
|
||||
method = method + "_" + next(iter(request[method]))
|
||||
@@ -858,7 +858,7 @@ async def get_smart_fixtures(
|
||||
protocol: SmartProtocol, *, discovery_info: dict[str, Any] | None, batch_size: int
|
||||
) -> list[FixtureResult]:
|
||||
"""Get fixture for new TAPO style protocol."""
|
||||
if isinstance(protocol, SmartCameraProtocol):
|
||||
if isinstance(protocol, SmartCamProtocol):
|
||||
test_calls, successes = await get_smart_camera_test_calls(protocol)
|
||||
child_wrapper: type[_ChildProtocolWrapper | _ChildCameraProtocolWrapper] = (
|
||||
_ChildCameraProtocolWrapper
|
||||
@@ -991,8 +991,8 @@ async def get_smart_fixtures(
|
||||
copy_folder = SMART_FOLDER
|
||||
else:
|
||||
# smart camera protocol
|
||||
model_info = SmartCamera._get_device_info(final, discovery_info)
|
||||
copy_folder = SMARTCAMERA_FOLDER
|
||||
model_info = SmartCamDevice._get_device_info(final, discovery_info)
|
||||
copy_folder = SMARTCAM_FOLDER
|
||||
hw_version = model_info.hardware_version
|
||||
sw_version = model_info.firmware_version
|
||||
model = model_info.long_name
|
||||
|
@@ -13,7 +13,7 @@ from typing import Any, NamedTuple
|
||||
from kasa.device_type import DeviceType
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.smart import SmartDevice
|
||||
from kasa.smartcamera import SmartCamera
|
||||
from kasa.smartcam import SmartCamDevice
|
||||
|
||||
|
||||
class SupportedVersion(NamedTuple):
|
||||
@@ -48,7 +48,7 @@ README_FILENAME = "README.md"
|
||||
IOT_FOLDER = "tests/fixtures/iot/"
|
||||
SMART_FOLDER = "tests/fixtures/smart/"
|
||||
SMART_CHILD_FOLDER = "tests/fixtures/smart/child"
|
||||
SMARTCAMERA_FOLDER = "tests/fixtures/smartcamera/"
|
||||
SMARTCAM_FOLDER = "tests/fixtures/smartcam/"
|
||||
|
||||
|
||||
def generate_supported(args):
|
||||
@@ -65,7 +65,7 @@ def generate_supported(args):
|
||||
_get_supported_devices(supported, IOT_FOLDER, IotDevice)
|
||||
_get_supported_devices(supported, SMART_FOLDER, SmartDevice)
|
||||
_get_supported_devices(supported, SMART_CHILD_FOLDER, SmartDevice)
|
||||
_get_supported_devices(supported, SMARTCAMERA_FOLDER, SmartCamera)
|
||||
_get_supported_devices(supported, SMARTCAM_FOLDER, SmartCamDevice)
|
||||
|
||||
readme_updated = _update_supported_file(
|
||||
README_FILENAME, _supported_summary(supported), print_diffs
|
||||
@@ -208,7 +208,7 @@ def _supported_text(
|
||||
def _get_supported_devices(
|
||||
supported: dict[str, Any],
|
||||
fixture_location: str,
|
||||
device_cls: type[IotDevice | SmartDevice | SmartCamera],
|
||||
device_cls: type[IotDevice | SmartDevice | SmartCamDevice],
|
||||
):
|
||||
for file in Path(fixture_location).glob("*.json"):
|
||||
with file.open() as f:
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
SMARTCAMERA_REQUESTS: list[dict] = [
|
||||
SMARTCAM_REQUESTS: list[dict] = [
|
||||
{"getAlertTypeList": {"msg_alarm": {"name": "alert_type"}}},
|
||||
{"getNightVisionCapability": {"image_capability": {"name": ["supplement_lamp"]}}},
|
||||
{"getDeviceInfo": {"device_info": {"name": ["basic_info"]}}},
|
Reference in New Issue
Block a user