mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-02-18 00:39:58 +00:00
Add module support & query their information during update cycle (#243)
* Add module support & modularize existing query This creates a base to expose more features on the supported devices. At the moment, the most visible change is that each update cycle gets information from all available modules: * Basic system info * Cloud (new) * Countdown (new) * Antitheft (new) * Schedule (new) * Time (existing, implements the time/timezone handling) * Emeter (existing, partially separated from smartdevice) * Fix imports * Fix linting * Use device host instead of alias in module repr * Add property to list available modules, print them in cli state report * usage: fix the get_realtime query * separate usage from schedule to avoid multi-inheritance * Fix module querying * Add is_supported property to modules
This commit is contained in:
@@ -3,6 +3,7 @@ import logging
|
||||
import re
|
||||
from typing import Any, Dict, NamedTuple, cast
|
||||
|
||||
from .modules import Antitheft, Cloud, Countdown, Emeter, Schedule, Time, Usage
|
||||
from .smartdevice import DeviceType, SmartDevice, SmartDeviceException, requires_update
|
||||
|
||||
|
||||
@@ -109,13 +110,19 @@ class SmartBulb(SmartDevice):
|
||||
"""
|
||||
|
||||
LIGHT_SERVICE = "smartlife.iot.smartbulb.lightingservice"
|
||||
TIME_SERVICE = "smartlife.iot.common.timesetting"
|
||||
SET_LIGHT_METHOD = "transition_light_state"
|
||||
emeter_type = "smartlife.iot.common.emeter"
|
||||
|
||||
def __init__(self, host: str) -> None:
|
||||
super().__init__(host=host)
|
||||
self.emeter_type = "smartlife.iot.common.emeter"
|
||||
self._device_type = DeviceType.Bulb
|
||||
self.add_module("schedule", Schedule(self, "smartlife.iot.common.schedule"))
|
||||
self.add_module("usage", Usage(self, "smartlife.iot.common.schedule"))
|
||||
self.add_module("antitheft", Antitheft(self, "smartlife.iot.common.anti_theft"))
|
||||
self.add_module("time", Time(self, "smartlife.iot.common.timesetting"))
|
||||
self.add_module("emeter", Emeter(self, self.emeter_type))
|
||||
self.add_module("countdown", Countdown(self, "countdown"))
|
||||
self.add_module("cloud", Cloud(self, "smartlife.iot.common.cloud"))
|
||||
|
||||
@property # type: ignore
|
||||
@requires_update
|
||||
|
||||
Reference in New Issue
Block a user