| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 81d3731 commit cc22f72
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -293,6 +293,7 @@ All Tapo devices require authentication.<br>Hub-Connected Devices may work acros | |||
| 293 | 293 | - Hardware: 2.0 (EU) / Firmware: 1.4.3 | |
| 294 | 294 | - **C220** | |
| 295 | 295 | - Hardware: 1.0 (EU) / Firmware: 1.2.2 | |
| 296 | + - Hardware: 1.0 (EU) / Firmware: 1.2.5 | ||
| 296 | 297 | - **C225** | |
| 297 | 298 | - Hardware: 2.0 (US) / Firmware: 1.0.11 | |
| 298 | 299 | - **C325WB** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,11 @@ | |||
| 44 | 44 | {"getWhitelampConfig": {"image": {"name": "switch"}}}, | |
| 45 | 45 | {"getMsgPushConfig": {"msg_push": {"name": ["chn1_msg_push_info"]}}}, | |
| 46 | 46 | {"getSdCardStatus": {"harddisk_manage": {"table": ["hd_info"]}}}, | |
| 47 | + { | ||
| 48 | + "getLinecrossingDetectionConfig": { | ||
| 49 | + "linecrossing_detection": {"name": ["detection", "arming_schedule"]} | ||
| 50 | + } | ||
| 51 | + }, | ||
| 47 | 52 | {"getCircularRecordingConfig": {"harddisk_manage": {"name": "harddisk"}}}, | |
| 48 | 53 | {"getRecordPlan": {"record_plan": {"name": ["chn1_channel"]}}}, | |
| 49 | 54 | {"getAudioConfig": {"audio_config": {"name": ["speaker", "microphone"]}}}, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | """Package for supporting tapo-branded cameras.""" | |
| 2 | 2 | ||
| 3 | + from .detectionmodule import DetectionModule | ||
| 3 | 4 | from .smartcamchild import SmartCamChild | |
| 4 | 5 | from .smartcamdevice import SmartCamDevice | |
| 5 | 6 | ||
| 6 | - __all__ = ["SmartCamDevice", "SmartCamChild"] | ||
| 7 | + __all__ = ["SmartCamDevice", "SmartCamChild", "DetectionModule"] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,58 @@ | |||
| 1 | + """SmartCamModule base class for all detections.""" | ||
| 2 | + | ||
| 3 | + from __future__ import annotations | ||
| 4 | + | ||
| 5 | + import logging | ||
| 6 | + | ||
| 7 | + from kasa.feature import Feature | ||
| 8 | + from kasa.smart.smartmodule import allow_update_after | ||
| 9 | + from kasa.smartcam.smartcammodule import SmartCamModule | ||
| 10 | + | ||
| 11 | + _LOGGER = logging.getLogger(__name__) | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + class DetectionModule(SmartCamModule): | ||
| 15 | + """SmartCamModule base class for all detections.""" | ||
| 16 | + | ||
| 17 | + #: Feature ID, filled by inheriting class | ||
| 18 | + DETECTION_FEATURE_ID: str = "" | ||
| 19 | + | ||
| 20 | + #: User-friendly short description, filled by inheriting class | ||
| 21 | + DETECTION_FEATURE_NAME: str = "" | ||
| 22 | + | ||
| 23 | + #: Feature setter method name, filled by inheriting class | ||
| 24 | + QUERY_SETTER_NAME: str = "" | ||
| 25 | + | ||
| 26 | + #: Feature section name, filled by inheriting class | ||
| 27 | + QUERY_SET_SECTION_NAME: str = "" | ||
| 28 | + | ||
| 29 | + def _initialize_features(self) -> None: | ||
| 30 | + """Initialize features after the initial update.""" | ||
| 31 | + self._add_feature( | ||
| 32 | + Feature( | ||
| 33 | + self._device, | ||
| 34 | + id=self.DETECTION_FEATURE_ID, | ||
| 35 | + name=self.DETECTION_FEATURE_NAME, | ||
| 36 | + container=self, | ||
| 37 | + attribute_getter="enabled", | ||
| 38 | + attribute_setter="set_enabled", | ||
| 39 | + type=Feature.Type.Switch, | ||
| 40 | + category=Feature.Category.Config, | ||
| 41 | + ) | ||
| 42 | + ) | ||
| 43 | + | ||
| 44 | + @property | ||
| 45 | + def enabled(self) -> bool: | ||
| 46 | + """Return the detection enabled state.""" | ||
| 47 | + return self.data[self.QUERY_SECTION_NAMES]["enabled"] == "on" | ||
| 48 | + | ||
| 49 | + @allow_update_after | ||
| 50 | + async def set_enabled(self, enable: bool) -> dict: | ||
| 51 | + """Set the detection enabled state.""" | ||
| 52 | + params = {"enabled": "on" if enable else "off"} | ||
| 53 | + return await self._device._query_setter_helper( | ||
| 54 | + self.QUERY_SETTER_NAME, | ||
| 55 | + self.QUERY_MODULE_NAME, | ||
| 56 | + self.QUERY_SET_SECTION_NAME, | ||
| 57 | + params, | ||
| 58 | + ) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,31 +2,40 @@ | |||
| 2 | 2 | ||
| 3 | 3 | from .alarm import Alarm | |
| 4 | 4 | from .babycrydetection import BabyCryDetection | |
| 5 | + from .barkdetection import BarkDetection | ||
| 5 | 6 | from .battery import Battery | |
| 6 | 7 | from .camera import Camera | |
| 7 | 8 | from .childdevice import ChildDevice | |
| 8 | 9 | from .childsetup import ChildSetup | |
| 9 | 10 | from .device import DeviceModule | |
| 11 | + from .glassdetection import GlassDetection | ||
| 10 | 12 | from .homekit import HomeKit | |
| 11 | 13 | from .led import Led | |
| 12 | 14 | from .lensmask import LensMask | |
| 15 | + from .linecrossingdetection import LineCrossingDetection | ||
| 13 | 16 | from .matter import Matter | |
| 17 | + from .meowdetection import MeowDetection | ||
| 14 | 18 | from .motiondetection import MotionDetection | |
| 15 | 19 | from .pantilt import PanTilt | |
| 16 | 20 | from .persondetection import PersonDetection | |
| 17 | 21 | from .petdetection import PetDetection | |
| 18 | 22 | from .tamperdetection import TamperDetection | |
| 19 | 23 | from .time import Time | |
| 24 | + from .vehicledetection import VehicleDetection | ||
| 20 | 25 | ||
| 21 | 26 | __all__ = [ | |
| 22 | 27 | "Alarm", | |
| 23 | 28 | "BabyCryDetection", | |
| 29 | + "BarkDetection", | ||
| 24 | 30 | "Battery", | |
| 25 | 31 | "Camera", | |
| 26 | 32 | "ChildDevice", | |
| 27 | 33 | "ChildSetup", | |
| 28 | 34 | "DeviceModule", | |
| 35 | + "GlassDetection", | ||
| 29 | 36 | "Led", | |
| 37 | + "LineCrossingDetection", | ||
| 38 | + "MeowDetection", | ||
| 30 | 39 | "PanTilt", | |
| 31 | 40 | "PersonDetection", | |
| 32 | 41 | "PetDetection", | |
@@ -36,4 +45,5 @@ | |||
| 36 | 45 | "MotionDetection", | |
| 37 | 46 | "LensMask", | |
| 38 | 47 | "TamperDetection", | |
| 48 | + "VehicleDetection", | ||
| 39 | 49 | ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,14 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | 5 | import logging | |
| 6 | 6 | ||
| 7 | - from ...feature import Feature | ||
| 8 | - from ...smart.smartmodule import allow_update_after | ||
| 9 | - from ..smartcammodule import SmartCamModule | ||
| 7 | + from kasa.smartcam.detectionmodule import DetectionModule | ||
| 10 | 8 | ||
| 11 | 9 | _LOGGER = logging.getLogger(__name__) | |
| 12 | 10 | ||
| 13 | 11 | ||
| 14 | - class BabyCryDetection(SmartCamModule): | ||
| 12 | + class BabyCryDetection(DetectionModule): | ||
| 15 | 13 | """Implementation of baby cry detection module.""" | |
| 16 | 14 | ||
| 17 | 15 | REQUIRED_COMPONENT = "babyCryDetection" | |
@@ -20,30 +18,7 @@ class BabyCryDetection(SmartCamModule): | |||
| 20 | 18 | QUERY_MODULE_NAME = "sound_detection" | |
| 21 | 19 | QUERY_SECTION_NAMES = "bcd" | |
| 22 | 20 | ||
| 23 | - def _initialize_features(self) -> None: | ||
| 24 | - """Initialize features after the initial update.""" | ||
| 25 | - self._add_feature( | ||
| 26 | - Feature( | ||
| 27 | - self._device, | ||
| 28 | - id="baby_cry_detection", | ||
| 29 | - name="Baby cry detection", | ||
| 30 | - container=self, | ||
| 31 | - attribute_getter="enabled", | ||
| 32 | - attribute_setter="set_enabled", | ||
| 33 | - type=Feature.Type.Switch, | ||
| 34 | - category=Feature.Category.Config, | ||
| 35 | - ) | ||
| 36 | - ) | ||
| 37 | - | ||
| 38 | - @property | ||
| 39 | - def enabled(self) -> bool: | ||
| 40 | - """Return the baby cry detection enabled state.""" | ||
| 41 | - return self.data["bcd"]["enabled"] == "on" | ||
| 42 | - | ||
| 43 | - @allow_update_after | ||
| 44 | - async def set_enabled(self, enable: bool) -> dict: | ||
| 45 | - """Set the baby cry detection enabled state.""" | ||
| 46 | - params = {"enabled": "on" if enable else "off"} | ||
| 47 | - return await self._device._query_setter_helper( | ||
| 48 | - "setBCDConfig", self.QUERY_MODULE_NAME, "bcd", params | ||
| 49 | - ) | ||
| 21 | + DETECTION_FEATURE_ID = "baby_cry_detection" | ||
| 22 | + DETECTION_FEATURE_NAME = "Baby cry detection" | ||
| 23 | + QUERY_SETTER_NAME = "setBCDConfig" | ||
| 24 | + QUERY_SET_SECTION_NAME = "bcd" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + """Implementation of bark detection module.""" | ||
| 2 | + | ||
| 3 | + from __future__ import annotations | ||
| 4 | + | ||
| 5 | + import logging | ||
| 6 | + | ||
| 7 | + from kasa.smartcam.detectionmodule import DetectionModule | ||
| 8 | + | ||
| 9 | + _LOGGER = logging.getLogger(__name__) | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + class BarkDetection(DetectionModule): | ||
| 13 | + """Implementation of bark detection module.""" | ||
| 14 | + | ||
| 15 | + REQUIRED_COMPONENT = "barkDetection" | ||
| 16 | + | ||
| 17 | + QUERY_GETTER_NAME = "getBarkDetectionConfig" | ||
| 18 | + QUERY_MODULE_NAME = "bark_detection" | ||
| 19 | + QUERY_SECTION_NAMES = "detection" | ||
| 20 | + | ||
| 21 | + DETECTION_FEATURE_ID = "bark_detection" | ||
| 22 | + DETECTION_FEATURE_NAME = "Bark detection" | ||
| 23 | + QUERY_SETTER_NAME = "setBarkDetectionConfig" | ||
| 24 | + QUERY_SET_SECTION_NAME = "detection" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + """Implementation of glass detection module.""" | ||
| 2 | + | ||
| 3 | + from __future__ import annotations | ||
| 4 | + | ||
| 5 | + import logging | ||
| 6 | + | ||
| 7 | + from kasa.smartcam.detectionmodule import DetectionModule | ||
| 8 | + | ||
| 9 | + _LOGGER = logging.getLogger(__name__) | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + class GlassDetection(DetectionModule): | ||
| 13 | + """Implementation of glass detection module.""" | ||
| 14 | + | ||
| 15 | + REQUIRED_COMPONENT = "glassDetection" | ||
| 16 | + | ||
| 17 | + QUERY_GETTER_NAME = "getGlassDetectionConfig" | ||
| 18 | + QUERY_MODULE_NAME = "glass_detection" | ||
| 19 | + QUERY_SECTION_NAMES = "detection" | ||
| 20 | + | ||
| 21 | + DETECTION_FEATURE_ID = "glass_detection" | ||
| 22 | + DETECTION_FEATURE_NAME = "Glass detection" | ||
| 23 | + QUERY_SETTER_NAME = "setGlassDetectionConfig" | ||
| 24 | + QUERY_SET_SECTION_NAME = "detection" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + """Implementation of line crossing detection module.""" | ||
| 2 | + | ||
| 3 | + from __future__ import annotations | ||
| 4 | + | ||
| 5 | + import logging | ||
| 6 | + | ||
| 7 | + from kasa.smartcam.detectionmodule import DetectionModule | ||
| 8 | + | ||
| 9 | + _LOGGER = logging.getLogger(__name__) | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + class LineCrossingDetection(DetectionModule): | ||
| 13 | + """Implementation of line crossing detection module.""" | ||
| 14 | + | ||
| 15 | + REQUIRED_COMPONENT = "linecrossingDetection" | ||
| 16 | + | ||
| 17 | + QUERY_GETTER_NAME = "getLinecrossingDetectionConfig" | ||
| 18 | + QUERY_MODULE_NAME = "linecrossing_detection" | ||
| 19 | + QUERY_SECTION_NAMES = "detection" | ||
| 20 | + | ||
| 21 | + DETECTION_FEATURE_ID = "line_crossing_detection" | ||
| 22 | + DETECTION_FEATURE_NAME = "Line crossing detection" | ||
| 23 | + QUERY_SETTER_NAME = "setLinecrossingDetectionConfig" | ||
| 24 | + QUERY_SET_SECTION_NAME = "detection" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + """Implementation of meow detection module.""" | ||
| 2 | + | ||
| 3 | + from __future__ import annotations | ||
| 4 | + | ||
| 5 | + import logging | ||
| 6 | + | ||
| 7 | + from kasa.smartcam.detectionmodule import DetectionModule | ||
| 8 | + | ||
| 9 | + _LOGGER = logging.getLogger(__name__) | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + class MeowDetection(DetectionModule): | ||
| 13 | + """Implementation of meow detection module.""" | ||
| 14 | + | ||
| 15 | + REQUIRED_COMPONENT = "meowDetection" | ||
| 16 | + | ||
| 17 | + QUERY_GETTER_NAME = "getMeowDetectionConfig" | ||
| 18 | + QUERY_MODULE_NAME = "meow_detection" | ||
| 19 | + QUERY_SECTION_NAMES = "detection" | ||
| 20 | + | ||
| 21 | + DETECTION_FEATURE_ID = "meow_detection" | ||
| 22 | + DETECTION_FEATURE_NAME = "Meow detection" | ||
| 23 | + QUERY_SETTER_NAME = "setMeowDetectionConfig" | ||
| 24 | + QUERY_SET_SECTION_NAME = "detection" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments