2024-02-22 22:09:38 +00:00
|
|
|
"""Implementation of report module."""
|
2024-04-16 18:21:20 +00:00
|
|
|
|
2024-04-17 13:39:24 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2024-02-22 22:09:38 +00:00
|
|
|
from ...feature import Feature
|
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
|
|
|
2024-05-11 18:28:18 +00:00
|
|
|
class ReportMode(SmartModule):
|
2024-02-22 22:09:38 +00:00
|
|
|
"""Implementation of report module."""
|
|
|
|
|
|
|
|
REQUIRED_COMPONENT = "report_mode"
|
|
|
|
QUERY_GETTER_NAME = "get_report_mode"
|
|
|
|
|
2024-11-10 18:55:13 +00:00
|
|
|
def _initialize_features(self) -> None:
|
2024-09-28 18:14:31 +00:00
|
|
|
"""Initialize features after the initial update."""
|
2024-02-22 22:09:38 +00:00
|
|
|
self._add_feature(
|
|
|
|
Feature(
|
2024-09-28 18:14:31 +00:00
|
|
|
self._device,
|
2024-05-07 09:13:35 +00:00
|
|
|
id="report_interval",
|
|
|
|
name="Report interval",
|
2024-02-22 22:09:38 +00:00
|
|
|
container=self,
|
|
|
|
attribute_getter="report_interval",
|
2024-07-30 18:23:07 +00:00
|
|
|
unit_getter=lambda: "s",
|
2024-04-23 17:20:12 +00:00
|
|
|
category=Feature.Category.Debug,
|
2024-06-25 16:30:36 +00:00
|
|
|
type=Feature.Type.Sensor,
|
2024-02-22 22:09:38 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2024-07-04 07:02:50 +00:00
|
|
|
def query(self) -> dict:
|
|
|
|
"""Query to execute during the update cycle."""
|
|
|
|
return {}
|
|
|
|
|
2024-02-22 22:09:38 +00:00
|
|
|
@property
|
2024-11-10 18:55:13 +00:00
|
|
|
def report_interval(self) -> int:
|
2024-02-22 22:09:38 +00:00
|
|
|
"""Reporting interval of a sensor device."""
|
|
|
|
return self._device.sys_info["report_interval"]
|