Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Aqara T1 wireless mini switch lumi.remote.b1acn02 #2871

Merged
merged 15 commits into from
Aug 11, 2024
72 changes: 71 additions & 1 deletion zhaquirks/xiaomi/aqara/sensor_switch_aq3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Xiaomi aqara button sensor."""

from zigpy import types
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import Basic, Identify, MultistateInput, OnOff
from zigpy.zcl.clusters.general import Basic, Identify, MultistateInput, OnOff, Ota

from zhaquirks import CustomCluster
from zhaquirks.const import (
Expand Down Expand Up @@ -30,6 +31,7 @@
LUMI,
BasicCluster,
DeviceTemperatureCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
XiaomiPowerConfiguration,
)
Expand All @@ -44,6 +46,7 @@
SHAKE = 18
SINGLE = 1
STATUS_TYPE_ATTR = 0x0055 # decimal = 85
OPPLE_MFG_CODE = 0x115F
muller119 marked this conversation as resolved.
Show resolved Hide resolved

MOVEMENT_TYPE = {
B1ACN01_HOLD: COMMAND_HOLD,
Expand All @@ -56,6 +59,17 @@
}


class OppleCluster(XiaomiAqaraE1Cluster):
"""Opple cluster."""
muller119 marked this conversation as resolved.
Show resolved Hide resolved

attributes = {
0x0009: ("mode", types.uint8_t, True),
}
muller119 marked this conversation as resolved.
Show resolved Hide resolved
attr_config = {0x0009: 0x01}
muller119 marked this conversation as resolved.
Show resolved Hide resolved

async def bind(self):
"""Bind cluster."""
muller119 marked this conversation as resolved.
Show resolved Hide resolved

class MultistateInputCluster(CustomCluster, MultistateInput):
"""Multistate input cluster."""

Expand Down Expand Up @@ -167,3 +181,59 @@ class SwitchAQ3B(XiaomiCustomDevice):
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
(LONG_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_RELEASE},
}


class SwitchAQ3B2(XiaomiCustomDevice):
"""Aqara button device - alternate version."""

signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=259
# device_version=1
# input_clusters=[0, 1, 3]
# output_clusters=[3, 6, 19]>
MODELS_INFO: [(LUMI, "lumi.remote.b1acn02")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: BUTTON_DEVICE_TYPE_B,
INPUT_CLUSTERS: [
Basic.cluster_id,
XiaomiPowerConfiguration.cluster_id,
Identify.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.REMOTE_CONTROL,
INPUT_CLUSTERS: [
BasicCluster,
XiaomiPowerConfiguration,
Identify.cluster_id,
MultistateInputCluster,
OppleCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
OppleCluster,
muller119 marked this conversation as resolved.
Show resolved Hide resolved
],
}
},
}

device_automation_triggers = {
(DOUBLE_PRESS, DOUBLE_PRESS): {COMMAND: COMMAND_DOUBLE},
(SHORT_PRESS, SHORT_PRESS): {COMMAND: COMMAND_SINGLE},
(LONG_PRESS, LONG_PRESS): {COMMAND: COMMAND_HOLD},
(LONG_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_RELEASE},
}
Loading