mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
f259a8f162
Address the inconsistent naming of smart modules by removing all "Module" suffixes and aligning filenames with class names. Removes the casting of modules to the correct module type now that is is redundant. Update the adding of iot modules to use the ModuleName class rather than a free string.
33 lines
814 B
Python
33 lines
814 B
Python
"""Module for led controls."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from ...interfaces.led import Led as LedInterface
|
|
from ..iotmodule import IotModule
|
|
|
|
|
|
class Led(IotModule, LedInterface):
|
|
"""Implementation of led controls."""
|
|
|
|
def query(self) -> dict:
|
|
"""Query to execute during the update cycle."""
|
|
return {}
|
|
|
|
@property
|
|
def mode(self):
|
|
"""LED mode setting.
|
|
|
|
"always", "never"
|
|
"""
|
|
return "always" if self.led else "never"
|
|
|
|
@property
|
|
def led(self) -> bool:
|
|
"""Return the state of the led."""
|
|
sys_info = self.data
|
|
return bool(1 - sys_info["led_off"])
|
|
|
|
async def set_led(self, state: bool):
|
|
"""Set the state of the led (night mode)."""
|
|
return await self.call("set_led_off", {"off": int(not state)})
|