Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kasa/smartcam/modules/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule

DURATION_MIN = 0
Expand Down Expand Up @@ -110,6 +111,7 @@ def alarm_sound(self) -> str:
"""Return current alarm sound."""
return self.data["getSirenConfig"]["siren_type"]

@allow_update_after
async def set_alarm_sound(self, sound: str) -> dict:
"""Set alarm sound.

Expand All @@ -134,6 +136,7 @@ def alarm_volume(self) -> int:
"""
return int(self.data["getSirenConfig"]["volume"])

@allow_update_after
async def set_alarm_volume(self, volume: int) -> dict:
"""Set alarm volume."""
if volume < VOLUME_MIN or volume > VOLUME_MAX:
Expand All @@ -145,6 +148,7 @@ def alarm_duration(self) -> int:
"""Return alarm duration."""
return self.data["getSirenConfig"]["duration"]

@allow_update_after
async def set_alarm_duration(self, duration: int) -> dict:
"""Set alarm volume."""
if duration < DURATION_MIN or duration > DURATION_MAX:
Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/babycrydetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging

from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -39,6 +40,7 @@ def enabled(self) -> bool:
"""Return the baby cry detection enabled state."""
return self.data["bcd"]["enabled"] == "on"

@allow_update_after
async def set_enabled(self, enable: bool) -> dict:
"""Set the baby cry detection enabled state."""
params = {"enabled": "on" if enable else "off"}
Expand Down
6 changes: 6 additions & 0 deletions kasa/smartcam/modules/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
:return: rtsp url with escaped credentials or None if no credentials or
camera is off.
"""
if self._device._is_hub_child:
return None

Check warning on line 103 in kasa/smartcam/modules/camera.py

View check run for this annotation

Codecov / codecov/patch

kasa/smartcam/modules/camera.py#L103

Added line #L103 was not covered by tests

streams = {
StreamResolution.HD: "stream1",
StreamResolution.SD: "stream2",
Expand All @@ -119,6 +122,9 @@

def onvif_url(self) -> str | None:
"""Return the onvif url."""
if self._device._is_hub_child:
return None

Check warning on line 126 in kasa/smartcam/modules/camera.py

View check run for this annotation

Codecov / codecov/patch

kasa/smartcam/modules/camera.py#L126

Added line #L126 was not covered by tests

return f"http://{self._device.host}:{ONVIF_PORT}/onvif/device_service"

async def _check_supported(self) -> bool:
Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from ...interfaces.led import Led as LedInterface
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule


Expand All @@ -19,6 +20,7 @@ def led(self) -> bool:
"""Return current led status."""
return self.data["config"]["enabled"] == "on"

@allow_update_after
async def set_led(self, enable: bool) -> dict:
"""Set led.

Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/lensmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging

from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule

_LOGGER = logging.getLogger(__name__)
Expand All @@ -23,6 +24,7 @@ def enabled(self) -> bool:
"""Return the lens mask state."""
return self.data["lens_mask_info"]["enabled"] == "on"

@allow_update_after
async def set_enabled(self, enable: bool) -> dict:
"""Set the lens mask state."""
params = {"enabled": "on" if enable else "off"}
Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/motiondetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging

from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -39,6 +40,7 @@ def enabled(self) -> bool:
"""Return the motion detection enabled state."""
return self.data["motion_det"]["enabled"] == "on"

@allow_update_after
async def set_enabled(self, enable: bool) -> dict:
"""Set the motion detection enabled state."""
params = {"enabled": "on" if enable else "off"}
Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/persondetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging

from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -39,6 +40,7 @@ def enabled(self) -> bool:
"""Return the person detection enabled state."""
return self.data["detection"]["enabled"] == "on"

@allow_update_after
async def set_enabled(self, enable: bool) -> dict:
"""Set the person detection enabled state."""
params = {"enabled": "on" if enable else "off"}
Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/tamperdetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging

from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -39,6 +40,7 @@ def enabled(self) -> bool:
"""Return the tamper detection enabled state."""
return self.data["tamper_det"]["enabled"] == "on"

@allow_update_after
async def set_enabled(self, enable: bool) -> dict:
"""Set the tamper detection enabled state."""
params = {"enabled": "on" if enable else "off"}
Expand Down
2 changes: 2 additions & 0 deletions kasa/smartcam/modules/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ...cachedzoneinfo import CachedZoneInfo
from ...feature import Feature
from ...interfaces import Time as TimeInterface
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule


Expand Down Expand Up @@ -73,6 +74,7 @@ def time(self) -> datetime:
"""Return device's current datetime."""
return self._time

@allow_update_after
async def set_time(self, dt: datetime) -> dict:
"""Set device time."""
if not dt.tzinfo:
Expand Down
Loading