mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Initial implementation for modularized smartdevice (#757)
The initial steps to modularize the smartdevice. Modules are initialized based on the component negotiation, and each module can indicate which features it supports and which queries should be run during the update cycle.
This commit is contained in:
21
kasa/smart/modules/devicemodule.py
Normal file
21
kasa/smart/modules/devicemodule.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Implementation of device module."""
|
||||
from typing import Dict
|
||||
|
||||
from ..smartmodule import SmartModule
|
||||
|
||||
|
||||
class DeviceModule(SmartModule):
|
||||
"""Implementation of device module."""
|
||||
|
||||
REQUIRED_COMPONENT = "device"
|
||||
|
||||
def query(self) -> Dict:
|
||||
"""Query to execute during the update cycle."""
|
||||
query = {
|
||||
"get_device_info": None,
|
||||
}
|
||||
# Device usage is not available on older firmware versions
|
||||
if self._device._components[self.REQUIRED_COMPONENT] >= 2:
|
||||
query["get_device_usage"] = None
|
||||
|
||||
return query
|
Reference in New Issue
Block a user