Add SmartCamera Led Module (#1249)

This commit is contained in:
Steven B. 2024-11-12 19:34:02 +00:00 committed by GitHub
parent 668ba748c5
commit 9d5e07b969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View File

@ -3,11 +3,13 @@
from .camera import Camera
from .childdevice import ChildDevice
from .device import DeviceModule
from .led import Led
from .time import Time
__all__ = [
"Camera",
"ChildDevice",
"DeviceModule",
"Led",
"Time",
]

View File

@ -0,0 +1,28 @@
"""Module for led controls."""
from __future__ import annotations
from ...interfaces.led import Led as LedInterface
from ..smartcameramodule import SmartCameraModule
class Led(SmartCameraModule, LedInterface):
"""Implementation of led controls."""
REQUIRED_COMPONENT = "led"
QUERY_GETTER_NAME = "getLedStatus"
QUERY_MODULE_NAME = "led"
QUERY_SECTION_NAMES = "config"
@property
def led(self) -> bool:
"""Return current led status."""
return self.data["config"]["enabled"] == "on"
async def set_led(self, enable: bool) -> dict:
"""Set led.
This should probably be a select with always/never/nightmode.
"""
params = {"enabled": "on"} if enable else {"enabled": "off"}
return await self.call("setLedStatus", {"led": {"config": params}})