2024-02-19 17:01:31 +00:00
|
|
|
"""Implementation of device module."""
|
2024-04-16 18:21:20 +00:00
|
|
|
|
2024-04-17 13:39:24 +00:00
|
|
|
from __future__ import annotations
|
2024-02-19 17:01:31 +00:00
|
|
|
|
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceModule(SmartModule):
|
|
|
|
"""Implementation of device module."""
|
|
|
|
|
|
|
|
REQUIRED_COMPONENT = "device"
|
|
|
|
|
2024-10-08 07:16:51 +00:00
|
|
|
async def _post_update_hook(self):
|
2024-07-04 07:02:50 +00:00
|
|
|
"""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.
|
|
|
|
"""
|
|
|
|
|
2024-04-17 13:39:24 +00:00
|
|
|
def query(self) -> dict:
|
2024-02-19 17:01:31 +00:00
|
|
|
"""Query to execute during the update cycle."""
|
|
|
|
query = {
|
|
|
|
"get_device_info": None,
|
|
|
|
}
|
|
|
|
# Device usage is not available on older firmware versions
|
2024-10-23 15:17:27 +00:00
|
|
|
# or child devices of hubs
|
|
|
|
if self.supported_version >= 2 and not self._device._is_hub_child:
|
2024-02-19 17:01:31 +00:00
|
|
|
query["get_device_usage"] = None
|
|
|
|
|
|
|
|
return query
|