mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 11:43:34 +00:00
cd0a74ca96
No devices in `fixtures/smart/child` support the `get_device_time` or `get_device_usage` methods so this PR tests for whether the device is a hub child and marks those modules/methods as not supported. This prevents features being erroneously created on child devices. It also moves the logic for getting the time from the parent module behind getting it from the child module which was masking the creation of these unsupported modules.
31 lines
856 B
Python
31 lines
856 B
Python
"""Implementation of device module."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
class DeviceModule(SmartModule):
|
|
"""Implementation of device module."""
|
|
|
|
REQUIRED_COMPONENT = "device"
|
|
|
|
async def _post_update_hook(self):
|
|
"""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
|