From 9d5e07b969313c6b23d25f4f5cf06a56be33b44b Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Tue, 12 Nov 2024 19:34:02 +0000 Subject: [PATCH] Add SmartCamera Led Module (#1249) --- kasa/experimental/modules/__init__.py | 2 ++ kasa/experimental/modules/led.py | 28 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 kasa/experimental/modules/led.py diff --git a/kasa/experimental/modules/__init__.py b/kasa/experimental/modules/__init__.py index 48c4c2ac..cf2b4377 100644 --- a/kasa/experimental/modules/__init__.py +++ b/kasa/experimental/modules/__init__.py @@ -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", ] diff --git a/kasa/experimental/modules/led.py b/kasa/experimental/modules/led.py new file mode 100644 index 00000000..0443d320 --- /dev/null +++ b/kasa/experimental/modules/led.py @@ -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}})