python-kasa/kasa/smart/modules/devicemodule.py

31 lines
864 B
Python
Raw Normal View History

"""Implementation of device module."""
from __future__ import annotations
from ..smartmodule import SmartModule
class DeviceModule(SmartModule):
"""Implementation of device module."""
REQUIRED_COMPONENT = "device"
2024-11-10 18:55:13 +00:00
async def _post_update_hook(self) -> None:
"""Perform actions after a device update.
Overrides the default behaviour to disable a module if the query returns
an error because this module is critical.
"""
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
# or child devices of hubs
if self.supported_version >= 2 and not self._device._is_hub_child:
query["get_device_usage"] = None
return query