zha-device-handlers icon indicating copy to clipboard operation
zha-device-handlers copied to clipboard

[Device Support Request] Aqara H1 wireless switch double rocker (model WRS-R02)

Open pavaroto opened this issue 4 years ago • 229 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] The device is not yet supported in ZHA but I saw that it received support in zigbee2mqtt https://www.zigbee2mqtt.io/devices/WRS-R02.html

Describe the solution you'd like A clear and concise description of what you want to happen. Support for single/double/triple/long press of left/right & both buttons.

Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.

{
  "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4447, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "2": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0003"
      ],
      "out_clusters": [
        "0x0006"
      ]
    },
    "4": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    },
    "5": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    },
    "6": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.remote.b28ac1",
  "class": "zigpy.device.Device"
}

Additional context Add any other context or screenshots about the feature request here.

The device was paired in home assistant's ZHA integration but not working properly. Both buttons behave as the same button. Below is the result of zha_event listening

Right button single press

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED OUT",
        "unique_id": "EDITED OUT",
        "device_id": "EDITED OUT",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-06-26T13:43:42.499260+00:00",
    "context": {
        "id": "b9d5f1afde358915f8619d1153832a07",
        "parent_id": null,
        "user_id": null
    }
}

Left button single press

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "EDITED OUT",
        "unique_id": "EDITED OUT",
        "device_id": "EDITED OUT",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-06-26T13:43:32.947572+00:00",
    "context": {
        "id": "d35c686ec88e197fa8f7adad07ad1b72",
        "parent_id": null,
        "user_id": null
    }
}

pavaroto avatar Jun 26 '21 13:06 pavaroto

what radio are you using? Can you enable debugging and post the logs for left and right button presses?

Adminiuga avatar Jul 07 '21 00:07 Adminiuga

I am using EZSP on a Xiaomi Gateway 3. I should mention that I am not a programmer and new to HA so I hope I managed to provide the correct info. Below is the extracted log lines for each button single press from the log file after enabling logger.

Left button press: 2021-07-07 20:42:19 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event zha_event[L]: device_ieee=54:ef:44:10:00:06:5c:96, unique_id=54:ef:44:10:00:06:5c:96:1:0x0006, device_id=5d00d3d3912f69bf88c9bdeaea66fd3f, endpoint_id=1, cluster_id=6, command=toggle, args=[]>

Right button press: 2021-07-07 20:42:22 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event zha_event[L]: device_ieee=54:ef:44:10:00:06:5c:96, unique_id=54:ef:44:10:00:06:5c:96:1:0x0006, device_id=5d00d3d3912f69bf88c9bdeaea66fd3f, endpoint_id=1, cluster_id=6, command=toggle, args=[]>

I reconnected the switch in ZHA in order to get the log as well:

[0x0000:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_req: [60, <Bool.false: 0>]
[0x93a3:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=235 command_id=Command.Report_Attributes>
[0x93a3:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=35>)]]
[0x93a3:1:0x0400] Attribute report received: measured_value=35
[0x93a3:1:0x0406] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=236 command_id=Command.Report_Attributes>
[0x93a3:1:0x0406] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=bitmap8, value=bitmap8.1>)]]
[0x93a3:1:0x0406] Attribute report received: occupancy=1
[0x93A3:1:0x0500]: Updated alarm state: 1
Received frame on uninitialized device 54:ef:44:10:00:06:5c:96 (Status.NEW) for endpoint: 1
[0xc6e6] Received ZCL while uninitialized on endpoint id 1, cluster 0x0006 id, hdr: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=True> manufacturer=None tsn=55 command_id=2>, payload: b''
Device 0xc6e6 (54:ef:44:10:00:06:5c:96) left the network
[0x4ded:zdo] ZDO request ZDOCmd.Active_EP_req: [0x0000]
[0x4ded:zdo] Unsupported ZDO request:ZDOCmd.Active_EP_req
Device 0xc6e6 (54:ef:44:10:00:06:5c:96) joined the network
[0xc6e6] Requesting 'Node Descriptor'
Tries remaining: 2
[0xc6e6] Extending timeout for 0x1f request
Device 0xc6e6 (54:ef:44:10:00:06:5c:96) joined the network
Skip initialization for existing device 54:ef:44:10:00:06:5c:96
[0xc6e6:zdo] ZDO request ZDOCmd.Device_annce: [0xC6E6, 54:ef:44:10:00:06:5c:96, 128]
[0xc6e6:zdo] ZDO request ZDOCmd.Node_Desc_req: [0x0000]
[0xc6e6:zdo] Unsupported ZDO request:ZDOCmd.Node_Desc_req
[0xc6e6] Node Descriptor: NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4447, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)
[0xc6e6] Discovering endpoints
Tries remaining: 3
[0xc6e6] Extending timeout for 0x21 request
[0xc6e6] Discovered endpoints: [1, 2, 3, 4, 5, 6]
[0xc6e6:1] Discovering endpoint information
Tries remaining: 3
[0xc6e6] Extending timeout for 0x23 request
[0xc6e6:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_req: [180, <Bool.true: 1>]
[0xc6e6:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=259, device_version=1, input_clusters=[0, 3, 1], output_clusters=[3, 6])
[0xc6e6] Extending timeout for 0x25 request
[0xc6e6:1:0x0000] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=37 command_id=Command.Read_Attributes_rsp>
[0xc6e6:1] Manufacturer: LUMI
[0xc6e6:1] Model: lumi.remote.b28ac1
[0xc6e6:2] Discovering endpoint information
Tries remaining: 3
[0xc6e6] Extending timeout for 0x27 request
[0xc6e6:3] Discovering endpoint information
Tries remaining: 3
[0xc6e6] Extending timeout for 0x29 request
[0xc6e6:3] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=3, profile=260, device_type=259, device_version=1, input_clusters=[3], output_clusters=[6])
[0xc6e6:4] Discovering endpoint information
Tries remaining: 3
[0xc6e6] Extending timeout for 0x2b request
[0xc6e6:5] Discovering endpoint information
Tries remaining: 3
[0xc6e6] Extending timeout for 0x2d request
[0xc6e6:6] Discovering endpoint information
Tries remaining: 3
[0xc6e6] Extending timeout for 0x2f request
Checking quirks for LUMI lumi.remote.b28ac1 (54:ef:44:10:00:06:5c:96)
Considering <class 'zhaquirks.xbee.xbee_io.XBeeSensor'>
Fail because endpoint list mismatch: {232, 230} {1, 2, 3, 4, 5, 6}
Considering <class 'zhaquirks.xbee.xbee3_io.XBee3Sensor'>
Fail because endpoint list mismatch: {232, 230} {1, 2, 3, 4, 5, 6}
Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'>
Fail because endpoint list mismatch: {1} {1, 2, 3, 4, 5, 6}
Considering <class 'zhaquirks.smartthings.multi.SmartthingsMultiPurposeSensor'>
Fail because endpoint list mismatch: {1} {1, 2, 3, 4, 5, 6}
Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'>
Fail because endpoint list mismatch: {1} {1, 2, 3, 4, 5, 6}
Considering <class 'zhaquirks.gledopto.soposhgu10.SoposhGU10'>
Fail because endpoint list mismatch: {11, 13} {1, 2, 3, 4, 5, 6}
Considering <class 'bellows.zigbee.application.EZSPCoordinator'>
Fail because endpoint list mismatch: {1} {1, 2, 3, 4, 5, 6}
device - 0xC6E6:54:ef:44:10:00:06:5c:96 entering async_device_initialized - is_new_join: True
device - 0xC6E6:54:ef:44:10:00:06:5c:96 has joined the ZHA zigbee network
[0xC6E6](lumi.remote.b28ac1): started configuration
[0xC6E6:ZDO](lumi.remote.b28ac1): 'async_configure' stage succeeded
[0xC6E6:1:0x0000]: finished channel configuration
[0xc6e6] Extending timeout for 0x31 request
[0xc6e6] Extending timeout for 0x33 request
[0xc6e6] Extending timeout for 0x35 request
[0xC6E6:1:0x0001]: bound 'power' cluster: Status.SUCCESS
[0xc6e6] Extending timeout for 0x37 request
[0xC6E6:1:0x0006]: bound 'on_off' cluster: Status.SUCCESS
[0xC6E6:1:0x0006]: finished channel configuration
[0xC6E6:3:0x0006]: bound 'on_off' cluster: Status.SUCCESS
[0xC6E6:3:0x0006]: finished channel configuration
[0xC6E6:3:0x0006]: 'async_configure' stage succeeded
[0xc6e6:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=55 command_id=Command.Configure_Reporting_rsp>
[0xC6E6:1:0x0001]: reporting 'battery_voltage' attr on 'power' cluster: 3600/10800/1: Result: '[[ConfigureReportingResponseRecord(status=0)]]'
[0xc6e6] Extending timeout for 0x39 request
[0xc6e6:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=57 command_id=Command.Configure_Reporting_rsp>
[0xC6E6:1:0x0001]: reporting 'battery_percentage_remaining' attr on 'power' cluster: 3600/10800/1: Result: '[[ConfigureReportingResponseRecord(status=134, direction=0, attrid=33)]]'
[0xC6E6:1:0x0001]: finished channel configuration
[0xC6E6:1:0x0000]: 'async_configure' stage succeeded
[0xC6E6:1:0x0001]: 'async_configure' stage succeeded
[0xC6E6:1:0x0006]: 'async_configure' stage succeeded
[0xC6E6](lumi.remote.b28ac1): completed configuration
[0xC6E6](lumi.remote.b28ac1): stored in registry: ZhaDeviceEntry(name='LUMI lumi.remote.b28ac1', ieee='54:ef:44:10:00:06:5c:96', last_seen=1625679580.81208)
[0xc6e6] Extending timeout for 0x3b request
[0xc6e6:1:0x0003] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=59 command_id=Command.Default_Response>
[0xC6E6:1:0x0003]: executed 'trigger_effect' command with args: '(2, 0)' kwargs: '{}' result: [64, <Status.SUCCESS: 0>]
[0xC6E6](lumi.remote.b28ac1): started initialization
[0xC6E6:ZDO](lumi.remote.b28ac1): 'async_initialize' stage succeeded
[0xC6E6:1:0x0000]: initializing channel: from_cache: False
[0xC6E6:1:0x0000]: finished channel configuration
[0xC6E6:1:0x0001]: initializing channel: from_cache: False
[0xc6e6] Extending timeout for 0x3d request
[0xC6E6:1:0x0006]: initializing channel: from_cache: False
[0xC6E6:1:0x0006]: finished channel configuration
[0xC6E6:3:0x0006]: initializing channel: from_cache: False
[0xC6E6:3:0x0006]: finished channel configuration
[0xC6E6:3:0x0006]: 'async_initialize' stage succeeded
[0xc6e6:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=61 command_id=Command.Read_Attributes_rsp>
[0xc6e6] Extending timeout for 0x3f request
[0xc6e6:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=63 command_id=Command.Read_Attributes_rsp>
[0xC6E6:1:0x0001]: finished channel configuration
[0xC6E6:1:0x0000]: 'async_initialize' stage succeeded
[0xC6E6:1:0x0001]: 'async_initialize' stage succeeded
[0xC6E6:1:0x0006]: 'async_initialize' stage succeeded
[0xC6E6](lumi.remote.b28ac1): power source: Battery or Unknown
[0xC6E6](lumi.remote.b28ac1): completed initialization
[0x93A3:1:0x0500]: Updated alarm state: 0
[0x4ded:zdo] ZDO request ZDOCmd.Active_EP_req: [0x0000]
[0x4ded:zdo] Unsupported ZDO request:ZDOCmd.Active_EP_req

pavaroto avatar Jul 07 '21 17:07 pavaroto

Leave the same debug log running, but press the left the. Right button and let me know the bed address of the device.

Adminiuga avatar Jul 11 '21 00:07 Adminiuga

I don't know what or where is the bed address of the device so I extracted the records for each button press from the home-assistant.log file. I hope it has the information you need. If not please give me more details on how to get it.

Left button press

2021-07-11 11:08:07 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'8610be7e'
2021-07-11 11:08:07 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame 69 (incomingMessageHandler) received: b'000401060001010001000090ffdce6c6ffff0311d602'
2021-07-11 11:08:07 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=6, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=144), 255, -36, 0xc6e6, 255, 255, b'\x11\xd6\x02']
2021-07-11 11:08:07 DEBUG (MainThread) [zigpy.zcl] [0xc6e6:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=True> manufacturer=None tsn=214 command_id=2>
2021-07-11 11:08:07 DEBUG (MainThread) [zigpy.zcl] [0xc6e6:1:0x0006] ZCL request 0x0002: []
2021-07-11 11:08:07 DEBUG (MainThread) [zigpy.zcl] [0xc6e6:1:0x0006] No handler for cluster command 2

Right button press

2021-07-11 11:10:03 DEBUG (bellows.thread_0) [bellows.uart] Sending: b'8520dd7e'
2021-07-11 11:10:03 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame 69 (incomingMessageHandler) received: b'000401060001010001000092ffdce6c6ffff0311d802'
2021-07-11 11:10:03 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=6, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=146), 255, -36, 0xc6e6, 255, 255, b'\x11\xd8\x02']
2021-07-11 11:10:03 DEBUG (MainThread) [zigpy.zcl] [0xc6e6:1:0x0006] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=False disable_default_response=True> manufacturer=None tsn=216 command_id=2>
2021-07-11 11:10:03 DEBUG (MainThread) [zigpy.zcl] [0xc6e6:1:0x0006] ZCL request 0x0002: []
2021-07-11 11:10:03 DEBUG (MainThread) [zigpy.zcl] [0xc6e6:1:0x0006] No handler for cluster command 2

pavaroto avatar Jul 11 '21 08:07 pavaroto

I don't know if xiaomi does some extra, manufacturer specific configuration, but it is not possible to discern between left and right clicks, as incoming data is virtually the same. In ZigBee spec compliant devices, button traffic comes from different endpoints, e.g endpoint 1 and endpoint 2. The commands are the same but endpoints are different. In this case the endpoint is always the same. Not sure what could be done here.

Adminiuga avatar Jul 11 '21 14:07 Adminiuga

Z2M looks having the possibility changing operating mode between LO and HA. Perhaps its sending the commands on different endpoints if being in LO mode ?

https://www.zigbee2mqtt.io/devices/WRS-R02.html

MattWestb avatar Jul 11 '21 14:07 MattWestb

What is LO and what is HA?

Adminiuga avatar Jul 13 '21 00:07 Adminiuga

LO = Light and occupancy (sending light and commands) and HA = sending "clicks".

MattWestb avatar Jul 13 '21 05:07 MattWestb

Any hope getting this device to work? I have two of these sitting in my drawer. Also confirmed working in deconz: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/4842

oliver989 avatar Sep 10 '21 19:09 oliver989

Would love to see support too. I was able to pair it on HomeAssistant via ZHA on A RPi with Raspbee2 but it does not show any entities except a malfunctioning power/battery entity. Events only show toggle commands for both buttons

thomasfr avatar Sep 15 '21 07:09 thomasfr

Same here for a WRS-R02, through ZHA (with a zigate) on a virtual machine running on a DS916+ Synology, only a faulty power/battery entity associated. Would also love a support. Beginner to HA but available to do some test if necessary. It should be pretty close to the WS-EUK02 operating mode (wall switch without neutral) if I should guess.

cray19003 avatar Oct 26 '21 22:10 cray19003

Same for me. To many, maybe things will change.

sy-per avatar Nov 04 '21 17:11 sy-per

Same here, but I'm adding some information:

From the User Manual:

  • They explain on the product overview that the switch have two modes: a """ single press in the high speed click mode and 7 functions in the multi-function mode including single press ... etc.""" (the feature that we all want)
  • On the switch modes section: they explain that basically you need to connect to their app (so through the bridge) to set the mode of the device

So I guess here we just need to find a way to send this command to the switch, things that zigbee2mqtt seems to allow https://www.zigbee2mqtt.io/devices/WRS-R02.html#operation-mode-enum

d-bourdon avatar Nov 24 '21 19:11 d-bourdon

The code used in Z2M: https://github.com/Koenkk/zigbee-herdsman-converters/blob/fa1faf7ec578df488a95dbb187aa0d18482a0f3f/devices/xiaomi.js#L1500-L1532 End point 1 (basic cluster i think) and attribute 0x0125 0x01 or 0x02 with manufacturerCode: 0x115f

I dont knowing if its using more endpoint for sending commands then the 1 or the rest is being used at all.

MattWestb avatar Nov 24 '21 20:11 MattWestb

Hi! I am exactly the same as you, model b28ac1, CC2531 and I can only do an automation that applies to the two buttons, there is no way to be able to do different automation with the buttons. It also does not detect double press or long press ...

Have you been able to find something else?

{ "event_type": "zha_event", "data": { "device_ieee": "54:ef:44:10:00:1a:e8:4b", "unique_id": "54:ef:44:10:00:1a:e8:4b:1:0x0006", "device_id": "dd6ee77957cc4d2c1ccbe1f76d59d14g", "endpoint_id": 1, "cluster_id": 6, "command": "toggle", "args": [] }, "origin": "LOCAL", "time_fired": "2021-11-26T17:58:37.452616+00:00", "context": { "id": "41740772fb9801e9c719797000c7fe4d", "parent_id": null, "user_id": null } }

I can use this automatization:

platform: event event_type: zha_event event_data: device_id: dd6ee77957cc4d2c1ccbe1f76d59d14g endpoint_id: 1

SergiTello avatar Nov 26 '21 18:11 SergiTello

Would be great to get this working with ZHA, is it on the roadmap?

NickDevoctomy avatar Dec 20 '21 12:12 NickDevoctomy

I recently bought an Aqara H1 wireless switch single rocker version (lumi.remote.b18ac1), and might be able to help.

Here's my custom_quirk file (https://gist.github.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0) which works for me, and it might be a starting point for the double rocker version.

~I'm a bit confused about the "operation mode" setting (the 0x9 in 0xfcc0 cluster), and the LO/HA mode. I don't think I've ever observed the "LO" behavior. No matter what value I set to 0x9, it never sends the toggle command. Instead, it sends click events via MultistateInputCluster just like AqaraOpple switch.~ ~This is different from the behavior described by @pavaroto . And I don't know why.~

~I'm using Conbee 2 with ZHA. Maybe it's relevant because it seems aqara devices "require the coodinator to have a Xiaomi manufacturer code to eventually reveal their full set of clusters" (source), or maybe my remote has a different firmware version.~

~P.S. I just realized @pavaroto is using Xiaomi Gateway 3. The Aqara H1 series is not officially supported on Xiaomi Gateway 3 (probably because Xiaomi Gateway 3 is not Zigbee 3.0). I'm not sure how well do they work together.~

P.S.2: The LO/HA mode works for me. I just realized I need to quickly press 5 times before making any changes to 0xfcc0 cluster.

xuxiaoqiao avatar Dec 25 '21 23:12 xuxiaoqiao

Hey everyone,

I've finished my prototype zhaquirk which (hopefully) will work with WRS-R02.

Just in case you don't have experience with custom zha quirks before, here are the steps:

  1. create a custom_zha_quirks folder under the home assistant config folder
  2. add the configurations below to enable zha quirks in the home assistant configuration.yaml
zha:
  enable_quirks: True
  custom_quirks_path: custom_zha_quirks
  1. put the aqara_h1_remote.py https://gist.github.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0#file-aqara_h1_remote-py in the custom_zha_quirks folder

  2. reload the ZHA home assistant integration, or just reboot the whole home assistant

  3. Home Assistant ➡️ Configuration ➡️ Devices & Services ➡️ Find the H1 Wireless Remote Device. You should see Quirk: aqara_h1_remote.RemoteH1DoubleRocker in the Device Info section. If it's not the case, maybe I've made some mistake in the quirk signature.

  4. (Just to be safe) remove the H1 remote device and pair again.

  5. Now in Home Assistant ➡️ Developer Tools ➡️ Events ➡️ Listen to events, fill zha_event and press start listening. When you press the Aqara H1 remote, you should see something.

  6. Then you might want to set the H1 Remote to your desired mode:

    1. Home Assistant ➡️ Configuration ➡️ Devices & Services ➡️ (Find your H1 Remote device) ➡️ Manage Clusters ➡️ Select AqaraRemoteManuSpecificCluster (Endpoint id: 1, Id: 0xfcc0, Type: in) ➡️ See "Cluster Attributes"
    2. For operation_mode (id: 0x0009): Fill your desired value, set "Manufacturer Code Override" to 4447, press "Set Zigbee Attribute". You may need to press H1 remote five times quickly to wake it up.
      • Value 0 means "command" mode, aka LO (Light and occupancy) mentioned by @MattWestb. In the "command" mode, the remote will send commands like "toggle" or "off". You can bind the device with a light (it works like ikea tradfri remotes). Pro: when you bind to a specific light, the button works even when home assistant is down. Con: Limited customization. Btw, it seems there's no way to differentiate the left/right button in this mode.
      • Value 1 means "event" mode. In the "event" mode, the remote will send generic click events to HA, and HA is responsible for the automation. When HA is down, the automation is down. But it allows more customization. I'm using this mode.
    3. For click_mode (id: 0x0125), set it similarly.
      • value 1 means single click mode. This mode has lower delay but only detects single click events. This is the default mode after factory reset.
      • value 2 means multiple click mode. This mode has a slightly higher delay but detects single/double/triple click and long press. I'm using this mode.
    4. FYI here's the behavior of my aqara h1 single button remote under different settings.
      • click_mode=1 and operation_mode=0
        • single click: sends toggle zha_event
      • click_mode=2 and operation_mode=0
        • single click: toggle zha_event
        • double click: off zha_event
      • click_mode=1 and operation_mode=1
        • single click: 1_single zha_event
      • click_mode=2 and operation_mode=1
        • single click: 1_single zha_event
        • double click: 1_double zha_event
        • triple click: 1_triple zha_event
        • long press: 1_hold zha_event
  7. Done. When you press the button, a zha_event will be triggered, which can be used in automation. The device trigger might help your automation as well demo of device trigger setting

xuxiaoqiao avatar Dec 26 '21 05:12 xuxiaoqiao

Hey everyone,

I've finished my prototype zhaquirk which (hopefully) will work with WRS-R02.

Just in case you don't have experience with custom zha quirks before, here are the steps:

Thank you very much for sharing your work. Unfortunately I was not able to integrate my double b28ac1. It still appears as LUMI lumi.remote.b28ac1 and I can not find the right Cluster (AqaraRemoteManuSpecificCluster). I am not sure that the quirks are working. Is there another option to pu in my config file ? Does anyone have the same problem or can help me ? Thanks. Cedric


Here is my config.yaml


default_config:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml


http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem
  ip_ban_enabled: true
  login_attempts_threshold: 5

sensor:
  - platform: systemmonitor
    resources:
      - type: disk_use_percent
        arg: /config
      - type: memory_free

tts:
  - platform: google_translate
    language: 'fr'
    base_url: https://*******

recorder:
  db_url: mysql://******

alexa:
  smart_home:

zha:
  enable_quirks: True
  custom_quirks_path: custom_zha_quirks

cray19003 avatar Dec 26 '21 22:12 cray19003

@cray19003 thanks for helping test it!

I'm not sure why it's not loading. If you have already created the aqara_h1_remote.py it should be loaded automatically. Here're a few questions that might help. You can also ping me on the HA discord (I'm xiaoqiao#8505 )

  1. Just to confirm, is your device signature the same as what @pavaroto has posted above? You can see the signature at "Device -> Zigbee Device Signature".
signature (click to expand)
{
  "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4447, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *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, *is_valid=True, *logical_type=, *user_descriptor_available=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "2": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0003"
      ],
      "out_clusters": [
        "0x0006"
      ]
    },
    "4": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    },
    "5": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    },
    "6": {
      "profile_id": null,
      "device_type": "",
      "in_clusters": [],
      "out_clusters": []
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.remote.b28ac1",
  "class": "zigpy.device.Device"
}
  1. Can you set log level to debug and see what's happening?
Set log level to debug in configration.yaml by adding the following block and reboot HA (click to expand)
logger:
  default: warning
  logs:
    homeassistant.components.zha: debug
    bellows.zigbee.application: debug
    bellows.ezsp: debug
    zigpy: debug
    zigpy_deconz.zigbee.application: debug
    zigpy_deconz.api: debug
    zigpy_xbee.zigbee.application: debug
    zigpy_xbee.api: debug
    zigpy_zigate: debug
    zigpy_znp: debug
    zhaquirks: debug

For me, it's working, and I can find the following content in the log, if yours doesn't work, it'll be good to know at which step it went wrong.

DEBUG (MainThread) [zhaquirks] Loading custom quirks from custom_zha_quirks
DEBUG (MainThread) [zhaquirks] Loading custom quirks module aqara_h1_remote
...
DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for LUMI lumi.remote.b18ac1 (xx:xx:xx:xx:xx:xx:xx:xx)
DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'aqara_h1_remote.RemoteH1SingleRocker'>
DEBUG (MainThread) [zigpy.quirks.registry] Found custom device replacement for xx:xx:xx:xx:xx:xx:xx:xx: <class 'aqara_h1_remote.RemoteH1SingleRocker'>

xuxiaoqiao avatar Dec 28 '21 06:12 xuxiaoqiao

This is my 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=127, maximum_incoming_transfer_size=100, server_mask=11264, maximum_outgoing_transfer_size=100, 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": "0x0103",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0003"
      ],
      "out_clusters": [
        "0x0006"
      ]
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.remote.b28ac1",
  "class": "zigpy.device.Device"
}

So I had to modify the quirk a little bit: remove in signature and replacement keys 2,4,5 and 6.

Now I have I think the last issue. I'm sending successfully to AqaraRemoteManuSpecificCluster -> selected_cluster: click_mode, value: 1, manufacturer_code_override: 4447 but still in Developers->Events when I push button I can see only toggle zha_event. Any advise how to have sole it?

mmatecki avatar Dec 28 '21 12:12 mmatecki

@mmatecki I'm sending successfully to AqaraRemoteManuSpecificCluster -> selected_cluster: click_mode, value: 1, manufacturer_code_override: 4447 but still in Developers->Events when I push button I can see only toggle zha_event

Whenclick_mode=1 and operation_mode=0, only toggle zha_event will be sent. I don’t know what’s your desired behavior but you probably want to set operation mode to 1? And if you need double/triple/long click you’ll want to set click_mode to 2

xuxiaoqiao avatar Dec 28 '21 16:12 xuxiaoqiao

FYI here's the behavior of my aqara h1 single button remote under different settings.

  • click_mode=1 and operation_mode=0
    • single click: sends toggle zha_event
  • click_mode=2 and operation_mode=0
    • single click: toggle zha_event
    • double click: off zha_event
  • click_mode=1 and operation_mode=1
    • single click: 1_single zha_event
  • click_mode=2 and operation_mode=1
    • single click: 1_single zha_event
    • double click: 1_double zha_event
    • triple click: 1_triple zha_event
    • long press: 1_hold zha_event

Actually, if the quirk works on the H1 2-button version, can someone post the full contents of zha_event it sends under different settings? could help me write the device_automation part.

xuxiaoqiao avatar Dec 28 '21 16:12 xuxiaoqiao

Thank you @xuxiaoqiao. Below you can find payloads. I have one more issue - the only left button is working. The right one is not generating any events for options when in payload you can see button in args.

click_mode: 1, operation_mode: 0

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0006",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:13:58.981917+00:00",
    "context": {
        "id": "50eed57c846823fe11e662e2f68645b7",
        "parent_id": null,
        "user_id": null
    }
}

click_mode: 2, operation_mode: 0

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0006",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:14:41.799728+00:00",
    "context": {
        "id": "1556b026018efcb25d059bc8ae47b113",
        "parent_id": null,
        "user_id": null
    }
}

no off command on double click.

click_mode: 1, operation_mode: 1

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "1_single",
        "args": {
            "button": 1,
            "press_type": "single",
            "attr_id": 85,
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:10:32.077832+00:00",
    "context": {
        "id": "79e96481cc43de077344fea9532ba65d",
        "parent_id": null,
        "user_id": null
    }
}

click_mode: 2, operation_mode: 1

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "1_single",
        "args": {
            "button": 1,
            "press_type": "single",
            "attr_id": 85,
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:12:13.290049+00:00",
    "context": {
        "id": "2dae12a19e5985fa449535d96c222510",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "1_double",
        "args": {
            "button": 1,
            "press_type": "double",
            "attr_id": 85,
            "value": 2
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:11:34.563156+00:00",
    "context": {
        "id": "3efc35ca0ebea44d6d22758ba6c9d0fe",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "1_triple",
        "args": {
            "button": 1,
            "press_type": "triple",
            "attr_id": 85,
            "value": 3
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:12:33.824133+00:00",
    "context": {
        "id": "c0b3e77599a3cf9a42fbc83da614231d",
        "parent_id": null,
        "user_id": null
    }
}
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "1_hold",
        "args": {
            "button": 1,
            "press_type": "hold",
            "attr_id": 85,
            "value": 0
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T18:12:53.595980+00:00",
    "context": {
        "id": "f046affc742eef3660b731925ddebe0b",
        "parent_id": null,
        "user_id": null
    }
}

mmatecki avatar Dec 28 '21 18:12 mmatecki

@mmatecki Great, seems we've made big progress. Thank you for your time.

My guess is that we should add MultistateInputCluster to endpoint 2. I probably need to look at a few examples first to figure out implementation details. But it shouldn't be too hard.

BTW, it seems if you press two buttons simultaneously in click_mode: 2, operation_mode: 1, it might trigger events from endpoint 3.

xuxiaoqiao avatar Dec 28 '21 18:12 xuxiaoqiao

Can you try https://gist.githubusercontent.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0/raw/7861c08cc19893b7b7d2fd2a56400d76d72df7da/aqara_h1_remote_exp1.py and see if it works? @mmatecki

xuxiaoqiao avatar Dec 28 '21 19:12 xuxiaoqiao

@xuxiaoqiao works perfectly well! Thank you.

Event for the left button:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:1:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 1,
        "cluster_id": 18,
        "command": "1_single",
        "args": {
            "button": 1,
            "press_type": "single",
            "attr_id": 85,
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T20:08:03.390331+00:00",
    "context": {
        "id": "138605fe76db9b7bc5a762e457d2c505",
        "parent_id": null,
        "user_id": null
    }
}

Event for the right button:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:2a:32:32",
        "unique_id": "54:ef:44:10:00:2a:32:32:2:0x0012",
        "device_id": "e8426aef5111750da533e3aa802f4407",
        "endpoint_id": 2,
        "cluster_id": 18,
        "command": "2_single",
        "args": {
            "button": 2,
            "press_type": "single",
            "attr_id": 85,
            "value": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-12-28T20:08:19.047120+00:00",
    "context": {
        "id": "a22ebe6a00391050ada8af61b19111a3",
        "parent_id": null,
        "user_id": null
    }
}

mmatecki avatar Dec 28 '21 20:12 mmatecki

Hi, I got the double button version and your quirk works fine, however i can't seem to change click mode and operation mode. I only get single click on each button.

And for those wondering how to create an automation with those events, below is an example to toggle a light with the right button. Replace the device_ieee, unique_id and device_id with the values you get when listening for a zha_event. The button action is also found is the zha_event ( as seen in the post above )

- id: '1640791149833'
  alias: H1 Right button
  description: ''
  trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_ieee: 54:ef:44:10:00:1b:09:dd
      unique_id: 54:ef:44:10:00:1b:09:dd:2:0x0012
      device_id: dea4120a7d912d1eafa097413bba89f5
  condition:
  - condition: template
    value_template: '{{ trigger.event.data.command == ''2_single'' }}'
  action:
  - type: toggle
    device_id: 62f7271352ef226d301c78ec023524e9
    entity_id: light.shelly_shdm_2_40f5200038b7
    domain: light
  mode: single

image

griphos avatar Dec 29 '21 16:12 griphos

however i can't seem to change click mode and operation mode. @griphos

Did you try quickly press the button five times when setting mode?

xuxiaoqiao avatar Dec 29 '21 17:12 xuxiaoqiao

Hey everyone, I have an update and a request.

First, I've just added device_automation_triggers section ( latest quirk ). Which means you can set "Device" triggers like below image

Please let me know if it works or not. I need more feedback before I create a PR.


And can anyone help confirm if the H1 remote supports "both buttons pressed at the same time" event? And if it does, does it support single/double/triple/long press? You might want to set mode to click_mode: 2, operation_mode: 1

xuxiaoqiao avatar Dec 29 '21 22:12 xuxiaoqiao