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
79 changes: 78 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.profiles import zha
from zigpy.zcl.clusters.general import Basic, Identify, MultistateInput, OnOff
import zigpy.types as types
muller119 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -56,6 +58,25 @@
}


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

def __init__(self, *args, **kwargs):
"""Init."""
self._current_state = None
super().__init__(*args, **kwargs)

Check warning on line 72 in zhaquirks/xiaomi/aqara/sensor_switch_aq3.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/xiaomi/aqara/sensor_switch_aq3.py#L71-L72

Added lines #L71 - L72 were not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed


async def bind(self):
"""Bind cluster."""
muller119 marked this conversation as resolved.
Show resolved Hide resolved
result = await super().bind()
await self.write_attributes(self.attr_config, manufacturer=OPPLE_MFG_CODE)
muller119 marked this conversation as resolved.
Show resolved Hide resolved
return result

Check warning on line 78 in zhaquirks/xiaomi/aqara/sensor_switch_aq3.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/xiaomi/aqara/sensor_switch_aq3.py#L76-L78

Added lines #L76 - L78 were not covered by tests

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

Expand Down Expand Up @@ -167,3 +188,59 @@
(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},
(B1ACN01_HOLD, LONG_PRESS): {COMMAND: COMMAND_HOLD},
(B1ACN01_RELEASE, LONG_RELEASE): {COMMAND: COMMAND_RELEASE},
muller119 marked this conversation as resolved.
Show resolved Hide resolved
}
Loading