python-kasa/kasa/smartcam/modules/led.py

29 lines
820 B
Python
Raw Normal View History

2024-11-12 19:34:02 +00:00
"""Module for led controls."""
from __future__ import annotations
from ...interfaces.led import Led as LedInterface
2024-11-23 08:07:47 +00:00
from ..smartcammodule import SmartCamModule
2024-11-12 19:34:02 +00:00
2024-11-23 08:07:47 +00:00
class Led(SmartCamModule, LedInterface):
2024-11-12 19:34:02 +00:00
"""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}})