Skip to content

Commit

Permalink
Fix Aqara motion sensor erroneous motion events (#2779)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJulianJES authored Mar 27, 2024
1 parent ef83953 commit 9ccb69a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
14 changes: 14 additions & 0 deletions zhaquirks/xiaomi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import zigpy.device
from zigpy.profiles import zha
from zigpy.quirks import CustomCluster, CustomDevice
from zigpy.typing import AddressingMode
from zigpy.zcl import foundation
from zigpy.zcl.clusters.general import (
AnalogInput,
Expand Down Expand Up @@ -543,6 +544,19 @@ class MotionCluster(LocalDataCluster, MotionOnEvent):
reset_s: int = 70


class LocalOccupancyCluster(LocalDataCluster, OccupancyCluster):
"""Local occupancy cluster that ignores messages from device."""

def handle_cluster_general_request(
self,
hdr: zigpy.zcl.foundation.ZCLHeader,
args: list,
*,
dst_addressing: AddressingMode | None = None,
) -> None:
"""Ignore occupancy attribute reports on this cluster, as they're invalid and sent by the sensor every hour."""


class DeviceTemperatureCluster(LocalDataCluster, DeviceTemperature):
"""Device Temperature Cluster."""

Expand Down
6 changes: 4 additions & 2 deletions zhaquirks/xiaomi/aqara/motion_agl02.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Xiaomi aqara T1 motion sensor device."""
from __future__ import annotations

from zigpy.profiles import zha
from zigpy.zcl.clusters.general import Identify, Ota
from zigpy.zcl.clusters.measurement import IlluminanceMeasurement, OccupancySensing
Expand All @@ -16,8 +18,8 @@
LUMI,
BasicCluster,
IlluminanceMeasurementCluster,
LocalOccupancyCluster,
MotionCluster,
OccupancyCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
Expand Down Expand Up @@ -78,7 +80,7 @@ def __init__(self, *args, **kwargs):
BasicCluster,
XiaomiPowerConfiguration,
Identify.cluster_id,
OccupancyCluster,
LocalOccupancyCluster,
MotionCluster,
IlluminanceMeasurementCluster,
XiaomiManufacturerCluster,
Expand Down
4 changes: 2 additions & 2 deletions zhaquirks/xiaomi/aqara/motion_agl04.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
)
from zhaquirks.xiaomi import (
DeviceTemperatureCluster,
LocalOccupancyCluster,
MotionCluster,
OccupancyCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
Expand Down Expand Up @@ -98,7 +98,7 @@ def __init__(self, *args, **kwargs):
XiaomiPowerConfiguration,
Identify.cluster_id,
DeviceTemperatureCluster,
OccupancyCluster,
LocalOccupancyCluster,
LocalMotionCluster,
OppleCluster,
],
Expand Down

0 comments on commit 9ccb69a

Please sign in to comment.