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
2 changes: 2 additions & 0 deletions kasa/experimental/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
28 changes: 28 additions & 0 deletions kasa/experimental/modules/led.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Module for led controls."""

from __future__ import annotations

from ...interfaces.led import Led as LedInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should get rid of the led interface at some point, but it's something for later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s my favourite interface. So simple 😄

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}})
Loading