2024-07-24 13:48:33 +00:00
|
|
|
"""Implementation of motion sensor module."""
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from ...feature import Feature
|
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
|
|
|
|
|
|
class MotionSensor(SmartModule):
|
|
|
|
"""Implementation of motion sensor module."""
|
|
|
|
|
|
|
|
REQUIRED_COMPONENT = "sensitivity"
|
|
|
|
|
2024-11-10 18:55:13 +00:00
|
|
|
def _initialize_features(self) -> None:
|
2024-07-24 13:48:33 +00:00
|
|
|
"""Initialize features."""
|
|
|
|
self._add_feature(
|
|
|
|
Feature(
|
|
|
|
self._device,
|
|
|
|
id="motion_detected",
|
|
|
|
name="Motion detected",
|
|
|
|
container=self,
|
|
|
|
attribute_getter="motion_detected",
|
|
|
|
icon="mdi:motion-sensor",
|
|
|
|
category=Feature.Category.Primary,
|
|
|
|
type=Feature.Type.BinarySensor,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
def query(self) -> dict:
|
|
|
|
"""Query to execute during the update cycle."""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
@property
|
2024-11-10 18:55:13 +00:00
|
|
|
def motion_detected(self) -> bool:
|
2024-07-24 13:48:33 +00:00
|
|
|
"""Return True if the motion has been detected."""
|
|
|
|
return self._device.sys_info["detected"]
|