Skip to content

Commit

Permalink
Add quirk for Aqara P1 contact sensor (#2822)
Browse files Browse the repository at this point in the history
* Add quirk for Aqara P1 contact sensor

* fix battery size

* switch cluster implementation

* update quirk
  • Loading branch information
dmulcahey authored Dec 27, 2023
1 parent f2a1ce5 commit 968315d
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions zhaquirks/xiaomi/aqara/magnet_ac01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Xiaomi aqara P1 contact sensor device."""

from zigpy.profiles import zha
import zigpy.types as t
from zigpy.zcl.clusters.general import Basic, Identify, OnOff, Ota, PowerConfiguration
from zigpy.zcl.clusters.security import IasZone

from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
XiaomiPowerConfigurationPercent,
)


class OppleCluster(XiaomiAqaraE1Cluster):
"""Opple cluster."""

class DetectionDistance(t.enum8):
"""Detection distance."""

TenMilimeters = 0x01
TwentyMilimeters = 0x02
ThirtyMilimeters = 0x03

attributes = {
0x010C: ("detection_distance", t.uint8_t, True),
}


class LumiMagnetAC01(XiaomiCustomDevice):
"""Custom device representing lumi.magnet.ac01."""

def __init__(self, *args, **kwargs):
"""Init."""
self.battery_size = 8
super().__init__(*args, **kwargs)

signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=1
# input_clusters=[0, 1, 3, 1280]
# output_clusters=[25]>
MODELS_INFO: [(LUMI, "lumi.magnet.ac01")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
},
}

replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
BasicCluster,
XiaomiPowerConfigurationPercent,
Identify.cluster_id,
OppleCluster,
],
OUTPUT_CLUSTERS: [OnOff.cluster_id, Ota.cluster_id],
},
},
}

0 comments on commit 968315d

Please sign in to comment.