mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Rename smartcamera to smartcam (#1300)
This commit is contained in:
@@ -24,9 +24,9 @@ from .protocols import (
|
||||
IotProtocol,
|
||||
SmartProtocol,
|
||||
)
|
||||
from .protocols.smartcameraprotocol import SmartCameraProtocol
|
||||
from .protocols.smartcamprotocol import SmartCamProtocol
|
||||
from .smart import SmartDevice
|
||||
from .smartcamera.smartcamera import SmartCamera
|
||||
from .smartcam import SmartCamDevice
|
||||
from .transports import (
|
||||
AesTransport,
|
||||
BaseTransport,
|
||||
@@ -151,10 +151,10 @@ def get_device_class_from_family(
|
||||
"SMART.TAPOSWITCH": SmartDevice,
|
||||
"SMART.KASAPLUG": SmartDevice,
|
||||
"SMART.TAPOHUB": SmartDevice,
|
||||
"SMART.TAPOHUB.HTTPS": SmartCamera,
|
||||
"SMART.TAPOHUB.HTTPS": SmartCamDevice,
|
||||
"SMART.KASAHUB": SmartDevice,
|
||||
"SMART.KASASWITCH": SmartDevice,
|
||||
"SMART.IPCAMERA.HTTPS": SmartCamera,
|
||||
"SMART.IPCAMERA.HTTPS": SmartCamDevice,
|
||||
"IOT.SMARTPLUGSWITCH": IotPlug,
|
||||
"IOT.SMARTBULB": IotBulb,
|
||||
}
|
||||
@@ -189,7 +189,7 @@ def get_protocol(
|
||||
"IOT.KLAP": (IotProtocol, KlapTransport),
|
||||
"SMART.AES": (SmartProtocol, AesTransport),
|
||||
"SMART.KLAP": (SmartProtocol, KlapTransportV2),
|
||||
"SMART.AES.HTTPS": (SmartCameraProtocol, SslAesTransport),
|
||||
"SMART.AES.HTTPS": (SmartCamProtocol, SslAesTransport),
|
||||
}
|
||||
if not (prot_tran_cls := supported_device_protocols.get(protocol_transport_key)):
|
||||
return None
|
||||
|
@@ -60,7 +60,7 @@ if TYPE_CHECKING:
|
||||
from .device import Device
|
||||
from .iot import modules as iot
|
||||
from .smart import modules as smart
|
||||
from .smartcamera import modules as smartcamera
|
||||
from .smartcam import modules as smartcam
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -139,8 +139,8 @@ class Module(ABC):
|
||||
)
|
||||
TriggerLogs: Final[ModuleName[smart.TriggerLogs]] = ModuleName("TriggerLogs")
|
||||
|
||||
# SMARTCAMERA only modules
|
||||
Camera: Final[ModuleName[smartcamera.Camera]] = ModuleName("Camera")
|
||||
# SMARTCAM only modules
|
||||
Camera: Final[ModuleName[smartcam.Camera]] = ModuleName("Camera")
|
||||
|
||||
def __init__(self, device: Device, module: str) -> None:
|
||||
self._device = device
|
||||
|
@@ -1,4 +1,4 @@
|
||||
"""Module for SmartCamera Protocol."""
|
||||
"""Module for SmartCamProtocol."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -46,8 +46,8 @@ class SingleRequest:
|
||||
request: dict[str, Any]
|
||||
|
||||
|
||||
class SmartCameraProtocol(SmartProtocol):
|
||||
"""Class for SmartCamera Protocol."""
|
||||
class SmartCamProtocol(SmartProtocol):
|
||||
"""Class for SmartCam Protocol."""
|
||||
|
||||
async def _handle_response_lists(
|
||||
self, response_result: dict[str, Any], method: str, retry_count: int
|
||||
@@ -123,7 +123,7 @@ class SmartCameraProtocol(SmartProtocol):
|
||||
"""
|
||||
method = request
|
||||
method_type = request[:3]
|
||||
snake_name = SmartCameraProtocol._make_snake_name(request)
|
||||
snake_name = SmartCamProtocol._make_snake_name(request)
|
||||
param = snake_name[4:]
|
||||
if (
|
||||
(short_method := method[:3])
|
@@ -168,7 +168,7 @@ class SmartProtocol(BaseProtocol):
|
||||
]
|
||||
|
||||
end = len(multi_requests)
|
||||
# The SmartCameraProtocol sends requests with a length 1 as a
|
||||
# The SmartCamProtocol sends requests with a length 1 as a
|
||||
# multipleRequest. The SmartProtocol doesn't so will never
|
||||
# raise_on_error
|
||||
raise_on_error = end == 1
|
||||
|
5
kasa/smartcam/__init__.py
Normal file
5
kasa/smartcam/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""Package for supporting tapo-branded cameras."""
|
||||
|
||||
from .smartcamdevice import SmartCamDevice
|
||||
|
||||
__all__ = ["SmartCamDevice"]
|
@@ -1,4 +1,4 @@
|
||||
"""Modules for SMARTCAMERA devices."""
|
||||
"""Modules for SMARTCAM devices."""
|
||||
|
||||
from .alarm import Alarm
|
||||
from .camera import Camera
|
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ...feature import Feature
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
DURATION_MIN = 0
|
||||
DURATION_MAX = 6000
|
||||
@@ -12,11 +12,11 @@ VOLUME_MIN = 0
|
||||
VOLUME_MAX = 10
|
||||
|
||||
|
||||
class Alarm(SmartCameraModule):
|
||||
class Alarm(SmartCamModule):
|
||||
"""Implementation of alarm module."""
|
||||
|
||||
# Needs a different name to avoid clashing with SmartAlarm
|
||||
NAME = "SmartCameraAlarm"
|
||||
NAME = "SmartCamAlarm"
|
||||
|
||||
REQUIRED_COMPONENT = "siren"
|
||||
QUERY_GETTER_NAME = "getSirenStatus"
|
@@ -10,14 +10,14 @@ from ...credentials import Credentials
|
||||
from ...device_type import DeviceType
|
||||
from ...feature import Feature
|
||||
from ...json import loads as json_loads
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
LOCAL_STREAMING_PORT = 554
|
||||
|
||||
|
||||
class Camera(SmartCameraModule):
|
||||
class Camera(SmartCamModule):
|
||||
"""Implementation of device module."""
|
||||
|
||||
QUERY_GETTER_NAME = "getLensMaskConfig"
|
@@ -1,10 +1,10 @@
|
||||
"""Module for child devices."""
|
||||
|
||||
from ...device_type import DeviceType
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
|
||||
class ChildDevice(SmartCameraModule):
|
||||
class ChildDevice(SmartCamModule):
|
||||
"""Implementation for child devices."""
|
||||
|
||||
REQUIRED_COMPONENT = "childControl"
|
@@ -3,10 +3,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ...feature import Feature
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
|
||||
class DeviceModule(SmartCameraModule):
|
||||
class DeviceModule(SmartCamModule):
|
||||
"""Implementation of device module."""
|
||||
|
||||
NAME = "devicemodule"
|
@@ -3,10 +3,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ...interfaces.led import Led as LedInterface
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
|
||||
class Led(SmartCameraModule, LedInterface):
|
||||
class Led(SmartCamModule, LedInterface):
|
||||
"""Implementation of led controls."""
|
||||
|
||||
REQUIRED_COMPONENT = "led"
|
@@ -3,13 +3,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ...feature import Feature
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
DEFAULT_PAN_STEP = 30
|
||||
DEFAULT_TILT_STEP = 10
|
||||
|
||||
|
||||
class PanTilt(SmartCameraModule):
|
||||
class PanTilt(SmartCamModule):
|
||||
"""Implementation of device_local_time."""
|
||||
|
||||
REQUIRED_COMPONENT = "ptz"
|
@@ -9,10 +9,10 @@ from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
|
||||
from ...cachedzoneinfo import CachedZoneInfo
|
||||
from ...feature import Feature
|
||||
from ...interfaces import Time as TimeInterface
|
||||
from ..smartcameramodule import SmartCameraModule
|
||||
from ..smartcammodule import SmartCamModule
|
||||
|
||||
|
||||
class Time(SmartCameraModule, TimeInterface):
|
||||
class Time(SmartCamModule, TimeInterface):
|
||||
"""Implementation of device_local_time."""
|
||||
|
||||
QUERY_GETTER_NAME = "getTimezone"
|
@@ -1,4 +1,4 @@
|
||||
"""Module for smartcamera."""
|
||||
"""Module for SmartCamDevice."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -8,15 +8,15 @@ from typing import Any
|
||||
from ..device import _DeviceInfo
|
||||
from ..device_type import DeviceType
|
||||
from ..module import Module
|
||||
from ..protocols.smartcameraprotocol import _ChildCameraProtocolWrapper
|
||||
from ..protocols.smartcamprotocol import _ChildCameraProtocolWrapper
|
||||
from ..smart import SmartChildDevice, SmartDevice
|
||||
from .modules import ChildDevice, DeviceModule
|
||||
from .smartcameramodule import SmartCameraModule
|
||||
from .smartcammodule import SmartCamModule
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SmartCamera(SmartDevice):
|
||||
class SmartCamDevice(SmartDevice):
|
||||
"""Class for smart cameras."""
|
||||
|
||||
# Modules that are called as part of the init procedure on first update
|
||||
@@ -41,7 +41,7 @@ class SmartCamera(SmartDevice):
|
||||
basic_info = info["getDeviceInfo"]["device_info"]["basic_info"]
|
||||
short_name = basic_info["device_model"]
|
||||
long_name = discovery_info["device_model"] if discovery_info else short_name
|
||||
device_type = SmartCamera._get_device_type_from_sysinfo(basic_info)
|
||||
device_type = SmartCamDevice._get_device_type_from_sysinfo(basic_info)
|
||||
fw_version_full = basic_info["sw_version"]
|
||||
firmware_version, firmware_build = fw_version_full.split(" ", maxsplit=1)
|
||||
return _DeviceInfo(
|
||||
@@ -73,7 +73,7 @@ class SmartCamera(SmartDevice):
|
||||
async def _initialize_smart_child(
|
||||
self, info: dict, child_components: dict
|
||||
) -> SmartDevice:
|
||||
"""Initialize a smart child device attached to a smartcamera."""
|
||||
"""Initialize a smart child device attached to a smartcam device."""
|
||||
child_id = info["device_id"]
|
||||
child_protocol = _ChildCameraProtocolWrapper(child_id, self.protocol)
|
||||
try:
|
||||
@@ -122,7 +122,7 @@ class SmartCamera(SmartDevice):
|
||||
|
||||
async def _initialize_modules(self) -> None:
|
||||
"""Initialize modules based on component negotiation response."""
|
||||
for mod in SmartCameraModule.REGISTERED_MODULES.values():
|
||||
for mod in SmartCamModule.REGISTERED_MODULES.values():
|
||||
if (
|
||||
mod.REQUIRED_COMPONENT
|
||||
and mod.REQUIRED_COMPONENT not in self._components
|
@@ -11,15 +11,15 @@ from ..smart.smartmodule import SmartModule
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import modules
|
||||
from .smartcamera import SmartCamera
|
||||
from .smartcamdevice import SmartCamDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SmartCameraModule(SmartModule):
|
||||
"""Base class for SMARTCAMERA modules."""
|
||||
class SmartCamModule(SmartModule):
|
||||
"""Base class for SMARTCAM modules."""
|
||||
|
||||
SmartCameraAlarm: Final[ModuleName[modules.Alarm]] = ModuleName("SmartCameraAlarm")
|
||||
SmartCamAlarm: Final[ModuleName[modules.Alarm]] = ModuleName("SmartCamAlarm")
|
||||
|
||||
#: Query to execute during the main update cycle
|
||||
QUERY_GETTER_NAME: str
|
||||
@@ -30,7 +30,7 @@ class SmartCameraModule(SmartModule):
|
||||
|
||||
REGISTERED_MODULES = {}
|
||||
|
||||
_device: SmartCamera
|
||||
_device: SmartCamDevice
|
||||
|
||||
def query(self) -> dict:
|
||||
"""Query to execute during the update cycle.
|
@@ -1,5 +0,0 @@
|
||||
"""Package for supporting tapo-branded cameras."""
|
||||
|
||||
from .smartcamera import SmartCamera
|
||||
|
||||
__all__ = ["SmartCamera"]
|
Reference in New Issue
Block a user