Add smartcam detection modules (#1389)
Some checks are pending
CI / Perform linting checks (3.13) (push) Waiting to run
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.13) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.11) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.12) (push) Blocked by required conditions
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.13) (push) Blocked by required conditions
CodeQL checks / Analyze (python) (push) Waiting to run

- Motion detection
- Person detection
- Tamper detection
- Baby Cry Detection
This commit is contained in:
Steven B.
2024-12-19 23:22:08 +00:00
committed by GitHub
parent b5f49a3c8a
commit d890b0a3ac
10 changed files with 386 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
"""Tests for smartcam baby cry detection module."""
from __future__ import annotations
from kasa import Device
from kasa.smartcam.smartcammodule import SmartCamModule
from ...device_fixtures import parametrize
babycrydetection = parametrize(
"has babycry detection",
component_filter="babyCryDetection",
protocol_filter={"SMARTCAM"},
)
@babycrydetection
async def test_babycrydetection(dev: Device):
"""Test device babycry detection."""
babycry = dev.modules.get(SmartCamModule.SmartCamBabyCryDetection)
assert babycry
bcde_feat = dev.features.get("baby_cry_detection")
assert bcde_feat
original_enabled = babycry.enabled
try:
await babycry.set_enabled(not original_enabled)
await dev.update()
assert babycry.enabled is not original_enabled
assert bcde_feat.value is not original_enabled
await babycry.set_enabled(original_enabled)
await dev.update()
assert babycry.enabled is original_enabled
assert bcde_feat.value is original_enabled
await bcde_feat.set_value(not original_enabled)
await dev.update()
assert babycry.enabled is not original_enabled
assert bcde_feat.value is not original_enabled
finally:
await babycry.set_enabled(original_enabled)

View File

@@ -0,0 +1,43 @@
"""Tests for smartcam motion detection module."""
from __future__ import annotations
from kasa import Device
from kasa.smartcam.smartcammodule import SmartCamModule
from ...device_fixtures import parametrize
motiondetection = parametrize(
"has motion detection", component_filter="detection", protocol_filter={"SMARTCAM"}
)
@motiondetection
async def test_motiondetection(dev: Device):
"""Test device motion detection."""
motion = dev.modules.get(SmartCamModule.SmartCamMotionDetection)
assert motion
mde_feat = dev.features.get("motion_detection")
assert mde_feat
original_enabled = motion.enabled
try:
await motion.set_enabled(not original_enabled)
await dev.update()
assert motion.enabled is not original_enabled
assert mde_feat.value is not original_enabled
await motion.set_enabled(original_enabled)
await dev.update()
assert motion.enabled is original_enabled
assert mde_feat.value is original_enabled
await mde_feat.set_value(not original_enabled)
await dev.update()
assert motion.enabled is not original_enabled
assert mde_feat.value is not original_enabled
finally:
await motion.set_enabled(original_enabled)

View File

@@ -0,0 +1,45 @@
"""Tests for smartcam person detection module."""
from __future__ import annotations
from kasa import Device
from kasa.smartcam.smartcammodule import SmartCamModule
from ...device_fixtures import parametrize
persondetection = parametrize(
"has person detection",
component_filter="personDetection",
protocol_filter={"SMARTCAM"},
)
@persondetection
async def test_persondetection(dev: Device):
"""Test device person detection."""
person = dev.modules.get(SmartCamModule.SmartCamPersonDetection)
assert person
pde_feat = dev.features.get("person_detection")
assert pde_feat
original_enabled = person.enabled
try:
await person.set_enabled(not original_enabled)
await dev.update()
assert person.enabled is not original_enabled
assert pde_feat.value is not original_enabled
await person.set_enabled(original_enabled)
await dev.update()
assert person.enabled is original_enabled
assert pde_feat.value is original_enabled
await pde_feat.set_value(not original_enabled)
await dev.update()
assert person.enabled is not original_enabled
assert pde_feat.value is not original_enabled
finally:
await person.set_enabled(original_enabled)

View File

@@ -0,0 +1,45 @@
"""Tests for smartcam tamper detection module."""
from __future__ import annotations
from kasa import Device
from kasa.smartcam.smartcammodule import SmartCamModule
from ...device_fixtures import parametrize
tamperdetection = parametrize(
"has tamper detection",
component_filter="tamperDetection",
protocol_filter={"SMARTCAM"},
)
@tamperdetection
async def test_tamperdetection(dev: Device):
"""Test device tamper detection."""
tamper = dev.modules.get(SmartCamModule.SmartCamTamperDetection)
assert tamper
tde_feat = dev.features.get("tamper_detection")
assert tde_feat
original_enabled = tamper.enabled
try:
await tamper.set_enabled(not original_enabled)
await dev.update()
assert tamper.enabled is not original_enabled
assert tde_feat.value is not original_enabled
await tamper.set_enabled(original_enabled)
await dev.update()
assert tamper.enabled is original_enabled
assert tde_feat.value is original_enabled
await tde_feat.set_value(not original_enabled)
await dev.update()
assert tamper.enabled is not original_enabled
assert tde_feat.value is not original_enabled
finally:
await tamper.set_enabled(original_enabled)