mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-19 05:48:02 +00:00
Add double click module for smart buttons
This commit is contained in:
@@ -12,6 +12,7 @@ from .color import Color
|
||||
from .colortemperature import ColorTemperature
|
||||
from .contactsensor import ContactSensor
|
||||
from .devicemodule import DeviceModule
|
||||
from .doubleclick import DoubleClick
|
||||
from .energy import Energy
|
||||
from .fan import Fan
|
||||
from .firmware import Firmware
|
||||
@@ -42,6 +43,7 @@ __all__ = [
|
||||
"DeviceModule",
|
||||
"ChildDevice",
|
||||
"BatterySensor",
|
||||
"DoubleClick",
|
||||
"HumiditySensor",
|
||||
"TemperatureSensor",
|
||||
"TemperatureControl",
|
||||
|
42
kasa/smart/modules/doubleclick.py
Normal file
42
kasa/smart/modules/doubleclick.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Module for double click enable."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ...feature import Feature
|
||||
from ..smartmodule import SmartModule, allow_update_after
|
||||
|
||||
|
||||
class DoubleClick(SmartModule):
|
||||
"""Implementation of double click module."""
|
||||
|
||||
REQUIRED_COMPONENT = "double_click"
|
||||
QUERY_GETTER_NAME = "get_double_click_info"
|
||||
|
||||
def _initialize_features(self) -> None:
|
||||
"""Initialize features after the initial update."""
|
||||
self._add_feature(
|
||||
Feature(
|
||||
self._device,
|
||||
id="double_click",
|
||||
name="Double click",
|
||||
container=self,
|
||||
attribute_getter="enabled",
|
||||
attribute_setter="set_enabled",
|
||||
type=Feature.Type.Switch,
|
||||
category=Feature.Category.Config,
|
||||
)
|
||||
)
|
||||
|
||||
def query(self) -> dict:
|
||||
"""Query to execute during the update cycle."""
|
||||
return {self.QUERY_GETTER_NAME: {}}
|
||||
|
||||
@property
|
||||
def enabled(self) -> bool:
|
||||
"""Return current double click enabled status."""
|
||||
return self.data["enable"]
|
||||
|
||||
@allow_update_after
|
||||
async def set_enabled(self, enable: bool) -> dict:
|
||||
"""Set double click enable."""
|
||||
return await self.call("set_double_click_info", {"enable": enable})
|
Reference in New Issue
Block a user