zha-device-handlers
zha-device-handlers copied to clipboard
[Device Support Request] Aqara 2 Button (WXKG17LM)
Is your feature request related to a problem? Please describe. I have Aqara E1 switch (WXKG17LM) it can be added to Home Assistant by ZHA integration but i can’t use it because ZHA is not seeing buttons only battery and identity button. I am using Convee 2 stick with the latest firmware (0x26780700)
Describe the solution you'd like Can you please help with adding it to Home Assistant.
Device signature
{
"node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4447, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)",
"endpoints": {
"1": {
"profile_id": 260,
"device_type": "0x0000",
"in_clusters": [
"0x0000",
"0x0001",
"0x0003",
"0x0012",
"0xfcc0"
],
"out_clusters": [
"0x0003",
"0x0006",
"0x0019"
]
},
"2": {
"profile_id": 260,
"device_type": "0x0000",
"in_clusters": [
"0x0012"
],
"out_clusters": [
"0x0006"
]
},
"3": {
"profile_id": 260,
"device_type": "0x0000",
"in_clusters": [
"0x0012"
],
"out_clusters": [
"0x0006"
]
}
},
"manufacturer": "LUMI",
"model": "lumi.remote.acn004",
"class": "zigpy.device.Device"
}
Diagnostic information
{
"home_assistant": {
"installation_type": "Home Assistant OS",
"version": "2022.9.7",
"dev": false,
"hassio": true,
"virtualenv": false,
"python_version": "3.10.5",
"docker": true,
"arch": "aarch64",
"timezone": "Europe/Moscow",
"os_name": "Linux",
"os_version": "5.15.61-v8",
"supervisor": "2022.09.1",
"host_os": "Home Assistant OS 9.0",
"docker_version": "20.10.17",
"chassis": "embedded",
"run_as_root": true
},
"custom_components": {
"hyperhdr": {
"version": "0.0.6",
"requirements": [
"hyperhdr-py==0.0.3"
]
},
"yandex_smart_home": {
"version": "0.5.2",
"requirements": []
},
"yandex_station": {
"version": "3.11.0",
"requirements": []
},
"climate_group": {
"version": "0.4.2",
"requirements": []
},
"average": {
"version": "2.3.0",
"requirements": []
},
"yandex_weather": {
"version": "1.2.0",
"requirements": []
},
"hacs": {
"version": "1.27.2",
"requirements": [
"aiogithubapi>=22.2.4"
]
},
"smartthinq_sensors": {
"version": "0.24.2",
"requirements": [
"pycountry>=20.7.3",
"xmltodict>=0.12.0",
"cchardet>=2.1.7"
]
}
},
"integration_manifest": {
"domain": "zha",
"name": "Zigbee Home Automation",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/zha",
"requirements": [
"bellows==0.33.1",
"pyserial==3.5",
"pyserial-asyncio==0.6",
"zha-quirks==0.0.79",
"zigpy-deconz==0.18.1",
"zigpy==0.50.3",
"zigpy-xbee==0.15.0",
"zigpy-zigate==0.9.2",
"zigpy-znp==0.8.2"
],
"usb": [
{
"vid": "10C4",
"pid": "EA60",
"description": "*2652*",
"known_devices": [
"slae.sh cc2652rb stick"
]
},
{
"vid": "1A86",
"pid": "55D4",
"description": "*sonoff*plus*",
"known_devices": [
"sonoff zigbee dongle plus v2"
]
},
{
"vid": "10C4",
"pid": "EA60",
"description": "*sonoff*plus*",
"known_devices": [
"sonoff zigbee dongle plus"
]
},
{
"vid": "10C4",
"pid": "EA60",
"description": "*tubeszb*",
"known_devices": [
"TubesZB Coordinator"
]
},
{
"vid": "1A86",
"pid": "7523",
"description": "*tubeszb*",
"known_devices": [
"TubesZB Coordinator"
]
},
{
"vid": "1A86",
"pid": "7523",
"description": "*zigstar*",
"known_devices": [
"ZigStar Coordinators"
]
},
{
"vid": "1CF1",
"pid": "0030",
"description": "*conbee*",
"known_devices": [
"Conbee II"
]
},
{
"vid": "10C4",
"pid": "8A2A",
"description": "*zigbee*",
"known_devices": [
"Nortek HUSBZB-1"
]
},
{
"vid": "0403",
"pid": "6015",
"description": "*zigate*",
"known_devices": [
"ZiGate+"
]
},
{
"vid": "10C4",
"pid": "EA60",
"description": "*zigate*",
"known_devices": [
"ZiGate"
]
},
{
"vid": "10C4",
"pid": "8B34",
"description": "*bv 2010/10*",
"known_devices": [
"Bitron Video AV2010/10"
]
}
],
"codeowners": [
"@dmulcahey",
"@adminiuga",
"@puddly"
],
"zeroconf": [
{
"type": "_esphomelib._tcp.local.",
"name": "tube*"
},
{
"type": "_zigate-zigbee-gateway._tcp.local.",
"name": "*zigate*"
}
],
"dependencies": [
"file_upload"
],
"after_dependencies": [
"onboarding",
"usb",
"zeroconf"
],
"iot_class": "local_polling",
"loggers": [
"aiosqlite",
"bellows",
"crccheck",
"pure_pcapy3",
"zhaquirks",
"zigpy",
"zigpy_deconz",
"zigpy_xbee",
"zigpy_zigate",
"zigpy_znp"
],
"is_built_in": true
},
"data": {
"ieee": "**REDACTED**",
"nwk": 26679,
"manufacturer": "LUMI",
"model": "lumi.remote.acn004",
"name": "LUMI lumi.remote.acn004",
"quirk_applied": false,
"quirk_class": "zigpy.device.Device",
"manufacturer_code": 4447,
"power_source": "Battery or Unknown",
"lqi": 255,
"rssi": -57,
"last_seen": "2022-09-29T06:21:10",
"available": true,
"device_type": "EndDevice",
"signature": {
"node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4447, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)",
"endpoints": {
"1": {
"profile_id": 260,
"device_type": "0x0000",
"in_clusters": [
"0x0000",
"0x0001",
"0x0003",
"0x0012",
"0xfcc0"
],
"out_clusters": [
"0x0003",
"0x0006",
"0x0019"
]
},
"2": {
"profile_id": 260,
"device_type": "0x0000",
"in_clusters": [
"0x0012"
],
"out_clusters": [
"0x0006"
]
},
"3": {
"profile_id": 260,
"device_type": "0x0000",
"in_clusters": [
"0x0012"
],
"out_clusters": [
"0x0006"
]
}
}
},
"active_coordinator": false,
"entities": [
{
"entity_id": "button.lumi_lumi_remote_acn004_identifybutton",
"name": "LUMI lumi.remote.acn004"
},
{
"entity_id": "sensor.lumi_lumi_remote_acn004_battery",
"name": "LUMI lumi.remote.acn004"
}
],
"neighbors": [],
"endpoint_names": [
{
"name": "ON_OFF_SWITCH"
},
{
"name": "ON_OFF_SWITCH"
},
{
"name": "ON_OFF_SWITCH"
}
],
"user_given_name": null,
"device_reg_id": "94e33ad35168ff8fcb3480b59c3baf84",
"area_id": null,
"cluster_details": {
"1": {
"device_type": {
"name": "ON_OFF_SWITCH",
"id": 0
},
"profile_id": 260,
"in_clusters": {
"0x0000": {
"endpoint_attribute": "basic",
"attributes": {
"0x0001": {
"attribute_name": "app_version",
"value": 7
},
"0x0004": {
"attribute_name": "manufacturer",
"value": "LUMI"
},
"0x0005": {
"attribute_name": "model",
"value": "lumi.remote.acn004"
}
},
"unsupported_attributes": {}
},
"0x0001": {
"endpoint_attribute": "power",
"attributes": {
"0x0020": {
"attribute_name": "battery_voltage",
"value": 29
}
},
"unsupported_attributes": {
"0x0020": {
"attribute_name": "battery_voltage"
},
"0x0021": {
"attribute_name": "battery_percentage_remaining"
},
"0x0033": {
"attribute_name": "battery_quantity"
},
"0x0031": {
"attribute_name": "battery_size"
}
}
},
"0x0003": {
"endpoint_attribute": "identify",
"attributes": {},
"unsupported_attributes": {}
},
"0x0012": {
"endpoint_attribute": "multistate_input",
"attributes": {
"0x0055": {
"attribute_name": "present_value",
"value": 1.0
}
},
"unsupported_attributes": {}
},
"0xfcc0": {
"endpoint_attribute": "manufacturer_specific",
"attributes": {},
"unsupported_attributes": {}
}
},
"out_clusters": {
"0x0003": {
"endpoint_attribute": "identify",
"attributes": {},
"unsupported_attributes": {}
},
"0x0006": {
"endpoint_attribute": "on_off",
"attributes": {},
"unsupported_attributes": {}
},
"0x0019": {
"endpoint_attribute": "ota",
"attributes": {},
"unsupported_attributes": {}
}
}
},
"2": {
"device_type": {
"name": "ON_OFF_SWITCH",
"id": 0
},
"profile_id": 260,
"in_clusters": {
"0x0012": {
"endpoint_attribute": "multistate_input",
"attributes": {
"0x0055": {
"attribute_name": "present_value",
"value": 1.0
}
},
"unsupported_attributes": {}
}
},
"out_clusters": {
"0x0006": {
"endpoint_attribute": "on_off",
"attributes": {},
"unsupported_attributes": {}
}
}
},
"3": {
"device_type": {
"name": "ON_OFF_SWITCH",
"id": 0
},
"profile_id": 260,
"in_clusters": {
"0x0012": {
"endpoint_attribute": "multistate_input",
"attributes": {},
"unsupported_attributes": {}
}
},
"out_clusters": {
"0x0006": {
"endpoint_attribute": "on_off",
"attributes": {},
"unsupported_attributes": {}
}
}
}
}
}
}
Additional logs
Additional context home-assistant.log
That would be my proposal:
remote_e1.py
"""Aqara E1-series wireless remote."""
from zigpy.profiles import zha
from zigpy.zcl.clusters.general import (
Basic,
Identify,
MultistateInput,
OnOff,
Ota,
PowerConfiguration,
)
from zhaquirks.const import (
ALT_DOUBLE_PRESS,
ALT_SHORT_PRESS,
ARGS,
BUTTON,
COMMAND,
COMMAND_OFF,
COMMAND_TOGGLE,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LEFT,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
RIGHT,
SHORT_PRESS,
TRIPLE_PRESS,
)
from zhaquirks.xiaomi import (
LUMI,
BasicCluster,
XiaomiCustomDevice,
)
from zhaquirks.xiaomi.aqara.opple_remote import (
COMMAND_1_DOUBLE,
COMMAND_1_HOLD,
COMMAND_1_SINGLE,
COMMAND_1_TRIPLE,
COMMAND_2_DOUBLE,
COMMAND_2_HOLD,
COMMAND_2_SINGLE,
COMMAND_2_TRIPLE,
COMMAND_3_DOUBLE,
COMMAND_3_HOLD,
COMMAND_3_SINGLE,
COMMAND_3_TRIPLE,
MultistateInputCluster,
)
from zhaquirks.xiaomi.aqara.remote_h1 import (
AqaraRemoteManuSpecificCluster,
PowerConfigurationClusterH1Remote,
)
BOTH_BUTTONS = "both_buttons"
class RemoteE1DoubleRocker1(XiaomiCustomDevice):
"""Aqara E1 Wireless Remote Double Rocker."""
manufacturer_id_override = 0x115F
signature = {
MODELS_INFO: [(LUMI, "lumi.remote.acn004")],
ENDPOINTS: {
1: {
# SizePrefixedSimpleDescriptor(
# endpoint=1, profile=260, device_type=0,
# input_clusters=["0x0000", "0x0001", "0x0003", "0x0012", "0xfcc0"],
# output_clusters=["0x0003", "0x0006", "0x0019"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
MultistateInput.cluster_id,
AqaraRemoteManuSpecificCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
# SizePrefixedSimpleDescriptor(
# endpoint=2, profile=260, device_type=0,
# input_clusters=["0x0012"], output_clusters=["0x0006"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
3: {
# SizePrefixedSimpleDescriptor(
# endpoint=3, profile=260, device_type=0,
# input_clusters=["0x0012"], output_clusters=["0x0006"])
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
BasicCluster,
Identify.cluster_id,
PowerConfigurationClusterH1Remote,
MultistateInputCluster,
AqaraRemoteManuSpecificCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
Ota.cluster_id,
],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
OnOff.cluster_id,
],
},
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
MultistateInputCluster,
],
OUTPUT_CLUSTERS: [
OnOff.cluster_id,
],
},
}
}
device_automation_triggers = {
# triggers when operation_mode == event
# the button doesn't send an release event after hold
(SHORT_PRESS, LEFT): {COMMAND: COMMAND_1_SINGLE},
(DOUBLE_PRESS, LEFT): {COMMAND: COMMAND_1_DOUBLE},
(TRIPLE_PRESS, LEFT): {COMMAND: COMMAND_1_TRIPLE},
(LONG_PRESS, LEFT): {COMMAND: COMMAND_1_HOLD},
(SHORT_PRESS, RIGHT): {COMMAND: COMMAND_2_SINGLE},
(DOUBLE_PRESS, RIGHT): {COMMAND: COMMAND_2_DOUBLE},
(TRIPLE_PRESS, RIGHT): {COMMAND: COMMAND_2_TRIPLE},
(LONG_PRESS, RIGHT): {COMMAND: COMMAND_2_HOLD},
(SHORT_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_SINGLE},
(DOUBLE_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_DOUBLE},
(TRIPLE_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_TRIPLE},
(LONG_PRESS, BOTH_BUTTONS): {COMMAND: COMMAND_3_HOLD},
# triggers when operation_mode == command
# known issue: it seems impossible to know which button being pressed
# when operation_mode == command
(ALT_SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE, ENDPOINT_ID: 1, ARGS: []},
(ALT_DOUBLE_PRESS, BUTTON): {COMMAND: COMMAND_OFF, ENDPOINT_ID: 1, ARGS: []},
}
Most of the code adapted from remote_h1.py
.
Device is supposed to have two click_mode
s:
# click_mode:
# 1 means single click mode, which is low latency (50ms) but only sends
# single click events.
# 2 means multiple click mode, which has a slightly higher latency but
# supports single/double/triple click and long press.
# default value after factory reset: 1.
According to 'herdsman-converters' this line will be required:
manufacturer_id_override = 0x115F
Please, comment the line to confirm if it's needed to work.
Thanks for your answer. I can try to check if the code upwords is working, but i need an instruction how to integrate it. Or i need to just remove and repair aqara switch?
You will need to enable the local quirk:
- https://github.com/zigpy/zha-device-handlers/discussions/693#discussioncomment-857274
Create inside the custom_zha_quirks
a new remote_e1.py
file.
Copy the code above inside the file.
Restart HA and pair the device again.
I have made changes in configurqation.yaml. Made a new folder named "custom_zha_quirks" and copied "remote_e1.py" there.
Now i can see the battery status and can see buttons then i'am creating new automatisations. But:
- There are no buttons in the card of this device
- after the second reboot and second repairing i was able to make it work but only single button press can fire events if a try to make long button press or double button press i recieve "single button press" message in event section
as i understood from Z2MQTT website this switch can work in 2 ways: 1 way will force them to be 2 button switch with only 2 buttons (As it is working right now) 2 way is less fast but user can use double clicks and long presses.
- There are no buttons in the card of this device
I'd say that's normal behavior if it's a remote: there's no switch and the keystrokes are handled via events.
2. only single button press can fire events if a try to make long button press or double button press i recieve "single button press" message in event section
That's exactly what is explained here:
Device is supposed to have two
click_mode
s:# click_mode: # 1 means single click mode, which is low latency (50ms) but only sends # single click events. # 2 means multiple click mode, which has a slightly higher latency but # supports single/double/triple click and long press. # default value after factory reset: 1.
Try changing the value of the click_mode
attribute to 2
.
You can do this from the device view --> manage cluster --> select the AqaraRemoteManuSpecificCluster
cluster --> select the click_mode
attribute
First get the current value, and then try to update the value to 2
.
Thanks. I tried to set the new value for click_mode but i failed even to recieve the state value.
Any errors from the log?
Yes, there are some. I have attachet log files home-assistant.log home-assistant1.log
Users are reporting problems for this device in the setting of attributes:
What I had to do when getting or setting attributes is first click the switch 5 times fast, then click either the set or get attribute button. This was the only way my switch would accept this. Don't know for sure if this helps, but it didn't work for me if I first clicked set or get, then woke up the switch by clicking 5 times fast. Also it only accepted the get and set for a really short time after I clicked the 5 times, so I would click 5 times fast immediately followed by clicking the get or set on my computer.
Refs:
- https://github.com/zigpy/zha-device-handlers/issues/940#issuecomment-1172558963
Thanks. Everything working now as expected. Thanks for your support.
Just to be sure. What was the problem? The setting value procedure? Are all the events working? From both buttons? And the both button event too?
Thanks in advanced.
Setting new value procedure is possible after clicking the button 5 times. Them the value can be read and written. All events are working with write and left buttons, i was able to get Short press button event, but wasn’t able to bet long press and double press long button events.
Have you tried with the operation_mode=1
(event)?
If not working, maybe listening to events can give us some info.
Hello. I tried to set operation_mode to 1, but it doesn’t work. After i’m setting up a value 1 and again reading the value i get operation_mode=o. Both buttons are only working in a short press mode, if i pressing them for a long time i receive long button press from right or left button.
Can you try to listen to zha_event
s?
That can be done from the developers view panel, events tab. Activate the zha_event
listening and try the buttons presses.
i have attached log from zha_events, but their is no double and long clicks on 3 button zha event.txt
It seems nothing more can be done here. Args from command are the same, so it is not possible to distinguish.