Allow update of camera modules after setting values (#1450)

This commit is contained in:
Steven B. 2025-01-14 15:11:12 +00:00 committed by GitHub
parent d03f535568
commit 68f50aa763
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 24 additions and 0 deletions

View File

@ -3,6 +3,7 @@
from __future__ import annotations from __future__ import annotations
from ...feature import Feature from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
DURATION_MIN = 0 DURATION_MIN = 0
@ -110,6 +111,7 @@ class Alarm(SmartCamModule):
"""Return current alarm sound.""" """Return current alarm sound."""
return self.data["getSirenConfig"]["siren_type"] return self.data["getSirenConfig"]["siren_type"]
@allow_update_after
async def set_alarm_sound(self, sound: str) -> dict: async def set_alarm_sound(self, sound: str) -> dict:
"""Set alarm sound. """Set alarm sound.
@ -134,6 +136,7 @@ class Alarm(SmartCamModule):
""" """
return int(self.data["getSirenConfig"]["volume"]) return int(self.data["getSirenConfig"]["volume"])
@allow_update_after
async def set_alarm_volume(self, volume: int) -> dict: async def set_alarm_volume(self, volume: int) -> dict:
"""Set alarm volume.""" """Set alarm volume."""
if volume < VOLUME_MIN or volume > VOLUME_MAX: if volume < VOLUME_MIN or volume > VOLUME_MAX:
@ -145,6 +148,7 @@ class Alarm(SmartCamModule):
"""Return alarm duration.""" """Return alarm duration."""
return self.data["getSirenConfig"]["duration"] return self.data["getSirenConfig"]["duration"]
@allow_update_after
async def set_alarm_duration(self, duration: int) -> dict: async def set_alarm_duration(self, duration: int) -> dict:
"""Set alarm volume.""" """Set alarm volume."""
if duration < DURATION_MIN or duration > DURATION_MAX: if duration < DURATION_MIN or duration > DURATION_MAX:

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import logging import logging
from ...feature import Feature from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -39,6 +40,7 @@ class BabyCryDetection(SmartCamModule):
"""Return the baby cry detection enabled state.""" """Return the baby cry detection enabled state."""
return self.data["bcd"]["enabled"] == "on" return self.data["bcd"]["enabled"] == "on"
@allow_update_after
async def set_enabled(self, enable: bool) -> dict: async def set_enabled(self, enable: bool) -> dict:
"""Set the baby cry detection enabled state.""" """Set the baby cry detection enabled state."""
params = {"enabled": "on" if enable else "off"} params = {"enabled": "on" if enable else "off"}

View File

@ -99,6 +99,9 @@ class Camera(SmartCamModule):
:return: rtsp url with escaped credentials or None if no credentials or :return: rtsp url with escaped credentials or None if no credentials or
camera is off. camera is off.
""" """
if self._device._is_hub_child:
return None
streams = { streams = {
StreamResolution.HD: "stream1", StreamResolution.HD: "stream1",
StreamResolution.SD: "stream2", StreamResolution.SD: "stream2",
@ -119,6 +122,9 @@ class Camera(SmartCamModule):
def onvif_url(self) -> str | None: def onvif_url(self) -> str | None:
"""Return the onvif url.""" """Return the onvif url."""
if self._device._is_hub_child:
return None
return f"http://{self._device.host}:{ONVIF_PORT}/onvif/device_service" return f"http://{self._device.host}:{ONVIF_PORT}/onvif/device_service"
async def _check_supported(self) -> bool: async def _check_supported(self) -> bool:

View File

@ -3,6 +3,7 @@
from __future__ import annotations from __future__ import annotations
from ...interfaces.led import Led as LedInterface from ...interfaces.led import Led as LedInterface
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
@ -19,6 +20,7 @@ class Led(SmartCamModule, LedInterface):
"""Return current led status.""" """Return current led status."""
return self.data["config"]["enabled"] == "on" return self.data["config"]["enabled"] == "on"
@allow_update_after
async def set_led(self, enable: bool) -> dict: async def set_led(self, enable: bool) -> dict:
"""Set led. """Set led.

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import logging import logging
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -23,6 +24,7 @@ class LensMask(SmartCamModule):
"""Return the lens mask state.""" """Return the lens mask state."""
return self.data["lens_mask_info"]["enabled"] == "on" return self.data["lens_mask_info"]["enabled"] == "on"
@allow_update_after
async def set_enabled(self, enable: bool) -> dict: async def set_enabled(self, enable: bool) -> dict:
"""Set the lens mask state.""" """Set the lens mask state."""
params = {"enabled": "on" if enable else "off"} params = {"enabled": "on" if enable else "off"}

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import logging import logging
from ...feature import Feature from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -39,6 +40,7 @@ class MotionDetection(SmartCamModule):
"""Return the motion detection enabled state.""" """Return the motion detection enabled state."""
return self.data["motion_det"]["enabled"] == "on" return self.data["motion_det"]["enabled"] == "on"
@allow_update_after
async def set_enabled(self, enable: bool) -> dict: async def set_enabled(self, enable: bool) -> dict:
"""Set the motion detection enabled state.""" """Set the motion detection enabled state."""
params = {"enabled": "on" if enable else "off"} params = {"enabled": "on" if enable else "off"}

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import logging import logging
from ...feature import Feature from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -39,6 +40,7 @@ class PersonDetection(SmartCamModule):
"""Return the person detection enabled state.""" """Return the person detection enabled state."""
return self.data["detection"]["enabled"] == "on" return self.data["detection"]["enabled"] == "on"
@allow_update_after
async def set_enabled(self, enable: bool) -> dict: async def set_enabled(self, enable: bool) -> dict:
"""Set the person detection enabled state.""" """Set the person detection enabled state."""
params = {"enabled": "on" if enable else "off"} params = {"enabled": "on" if enable else "off"}

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import logging import logging
from ...feature import Feature from ...feature import Feature
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -39,6 +40,7 @@ class TamperDetection(SmartCamModule):
"""Return the tamper detection enabled state.""" """Return the tamper detection enabled state."""
return self.data["tamper_det"]["enabled"] == "on" return self.data["tamper_det"]["enabled"] == "on"
@allow_update_after
async def set_enabled(self, enable: bool) -> dict: async def set_enabled(self, enable: bool) -> dict:
"""Set the tamper detection enabled state.""" """Set the tamper detection enabled state."""
params = {"enabled": "on" if enable else "off"} params = {"enabled": "on" if enable else "off"}

View File

@ -9,6 +9,7 @@ from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
from ...cachedzoneinfo import CachedZoneInfo from ...cachedzoneinfo import CachedZoneInfo
from ...feature import Feature from ...feature import Feature
from ...interfaces import Time as TimeInterface from ...interfaces import Time as TimeInterface
from ...smart.smartmodule import allow_update_after
from ..smartcammodule import SmartCamModule from ..smartcammodule import SmartCamModule
@ -73,6 +74,7 @@ class Time(SmartCamModule, TimeInterface):
"""Return device's current datetime.""" """Return device's current datetime."""
return self._time return self._time
@allow_update_after
async def set_time(self, dt: datetime) -> dict: async def set_time(self, dt: datetime) -> dict:
"""Set device time.""" """Set device time."""
if not dt.tzinfo: if not dt.tzinfo: