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

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

Open
pavaroto opened this issue Jun 26, 2021 · 229 comments
Labels
custom quirk available A custom quirk is available to solve the issue, but it's not merged in the repo yet Xiaomi Request/PR regarding a Xiaomi device

Comments

@pavaroto
Copy link

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
    }
}
@Adminiuga
Copy link
Contributor

Adminiuga commented Jul 7, 2021

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

@pavaroto
Copy link
Author

pavaroto commented Jul 7, 2021

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

@Adminiuga
Copy link
Contributor

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

@pavaroto
Copy link
Author

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

@Adminiuga
Copy link
Contributor

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.

@MattWestb
Copy link
Contributor

MattWestb commented Jul 11, 2021

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

@Adminiuga
Copy link
Contributor

What is LO and what is HA?

@MattWestb
Copy link
Contributor

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

@oliver989
Copy link

oliver989 commented Sep 10, 2021

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

@thomasfr
Copy link

thomasfr commented Sep 15, 2021

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

@cray19003
Copy link

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.

@sy-per
Copy link

sy-per commented Nov 4, 2021

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

@d-bourdon
Copy link

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

@MattWestb
Copy link
Contributor

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.

@SergiTello
Copy link

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

@NickDevoctomy
Copy link

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

@xuxiaoqiao
Copy link
Contributor

xuxiaoqiao commented Dec 25, 2021

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
Copy link
Contributor

xuxiaoqiao commented Dec 26, 2021

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

@cray19003
Copy link

cray19003 commented Dec 26, 2021

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

@xuxiaoqiao
Copy link
Contributor

xuxiaoqiao commented Dec 28, 2021

@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'>

@mmatecki
Copy link

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?

@xuxiaoqiao
Copy link
Contributor

@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
Copy link
Contributor

xuxiaoqiao commented Dec 28, 2021

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.

@mmatecki
Copy link

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
    }
}

@xuxiaoqiao
Copy link
Contributor

@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.

@mmatecki
Copy link

@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
    }
}

@griphos
Copy link

griphos commented Dec 29, 2021

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

@xuxiaoqiao
Copy link
Contributor

xuxiaoqiao commented Dec 29, 2021

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
Copy link
Contributor

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

@MarkL1969
Copy link

MarkL1969 commented Nov 3, 2023

Oh, correction. Digging a little more into quirks and device signatures I have to say that my H1 has longer complete signature compared to the others I find in the current quirk file.

The signature of my H1 is:

  "data": {
    "ieee": "**REDACTED**",
    "nwk": 48853,
    "manufacturer": "LUMI",
    "model": "lumi.remote.b28ac1",
    "name": "LUMI lumi.remote.b28ac1",
    "quirk_applied": false,
    "quirk_class": "zigpy.device.Device",
    "manufacturer_code": 4447,
    "power_source": "Battery or Unknown",
    "lqi": null,
    "rssi": null,
    "last_seen": "2023-11-03T13:11:41",
    "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=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": "0x0104",
          "device_type": "0x0105",
          "input_clusters": [
            "0x0000",
            "0x0001",
            "0x0003"
          ],
          "output_clusters": [
            "0x0003",
            "0x0006",
            "0x0008",
            "0x0300"
          ]
        },
        "2": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003"
          ],
          "output_clusters": [
            "0x0003",
            "0x0006"
          ]
        },
        "3": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003"
          ],
          "output_clusters": [
            "0x0006"
          ]
        },
        "4": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003",
            "0x0012"
          ],
          "output_clusters": [
            "0x0006"
          ]
        },
        "5": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003",
            "0x0012"
          ],
          "output_clusters": [
            "0x0006"
          ]
        },
        "6": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003",
            "0x0012"
          ],
          "output_clusters": [
            "0x0006"
          ]
        }
      },
      "manufacturer": "LUMI",
      "model": "lumi.remote.b28ac1"
    },

So now I could update the signature in the quirk but I don't know how to map the new endpoints...
Any help highly appreciated. :o)

@JaresTech
Copy link

JaresTech commented Nov 3, 2023

class RemoteH1DoubleRocker7(XiaomiCustomDevice):
"""Aqara H1 Wireless Remote Double Rocker Version WRS-R02, variant 7."""
signature = {
MODELS_INFO: [(LUMI, "lumi.remote.b28ac1")],
ENDPOINTS: {
1: {
# "1": {
# "profile_id": 104, "device_type": "0x0105",
# "in_clusters": ["0x0000", "0x0001", "0x0003"],
# "out_clusters": ["0x0003", "0x0006", "0x0008", "0x0300"] }
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Color.cluster_id,
],
},
2: {
# "2": {
# "profile_id": 104, "device_type": "0x0103",
# "in_clusters": ["0x0003"],
# "out_clusters": ["0x0003", "0x0006"] },
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
INPUT_CLUSTERS: [
Identify.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
],
},
3: {
# "3": {
# "profile_id": 104, "device_type": "0x0103",
# "in_clusters": ["0x0003"],
# "out_clusters": ["0x0006"] },
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
INPUT_CLUSTERS: [Identify.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
4: {
# "4": {
# "profile_id": 104, "device_type": "0x0103",
# "in_clusters": ["0x0003", "0x0012"]
# "out_clusters": ["0x0006"]
# }
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
5: {
# "5": {
# "profile_id": 104, "device_type": "0x0103",
# "in_clusters": ["0x0003", "0x0012"]
# "out_clusters": ["0x0006"]
# }
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
6: {
# "6": {
# "profile_id": 104 "device_type": "0x0103",
# "in_clusters": ["0x0003", "0x0012"]
# "out_clusters": ["0x0006"]
# }
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
OUTPUT_CLUSTERS: [OnOff.cluster_id],
},
},
}
replacement = RemoteH1DoubleRocker1.replacement
device_automation_triggers = RemoteH1DoubleRocker1.device_automation_triggers

try adding the above to the bottom of the quirk file. make sure the indents are spot on or it wont like it.

@JaresTech
Copy link

class RemoteH1DoubleRocker7(XiaomiCustomDevice):
"""Aqara H1 Wireless Remote Double Rocker Version WRS-R02, variant 7."""

signature = {
    MODELS_INFO: [(LUMI, "lumi.remote.b28ac1")],
    ENDPOINTS: {
        1: {
            # "1": {
            # "profile_id": 104, "device_type": "0x0105",
            # "in_clusters": ["0x0000", "0x0001", "0x0003"],
            # "out_clusters": ["0x0003", "0x0006", "0x0008", "0x0300"] }
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
            INPUT_CLUSTERS: [
                Basic.cluster_id,
                PowerConfiguration.cluster_id,
                Identify.cluster_id,
            ],
            OUTPUT_CLUSTERS: [
                Identify.cluster_id,
                OnOff.cluster_id,
                LevelControl.cluster_id,
                Color.cluster_id,
            ],
        },
        2: {
            # "2": {
            # "profile_id": 104, "device_type": "0x0103",
            # "in_clusters": ["0x0003"],
            # "out_clusters": ["0x0003", "0x0006"] },
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
            INPUT_CLUSTERS: [
                Identify.cluster_id,
            ],
            OUTPUT_CLUSTERS: [
                Identify.cluster_id,
                OnOff.cluster_id,
            ],
        },
        3: {
            # "3": {
            # "profile_id": 104, "device_type": "0x0103",
            # "in_clusters": ["0x0003"],
            # "out_clusters": ["0x0006"] },
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
            INPUT_CLUSTERS: [Identify.cluster_id],
            OUTPUT_CLUSTERS: [OnOff.cluster_id],
        },
        4: {
            # "4": {
            # "profile_id": 104, "device_type": "0x0103",
            # "in_clusters": ["0x0003", "0x0012"]
            # "out_clusters": ["0x0006"]
            # }
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
            INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
            OUTPUT_CLUSTERS: [OnOff.cluster_id],
        },
        5: {
            # "5": {
            # "profile_id": 104, "device_type": "0x0103",
            # "in_clusters": ["0x0003", "0x0012"]
            # "out_clusters": ["0x0006"]
            # }
            PROFILE_ID: zha.PROFILE_ID,
            DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
            INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
            OUTPUT_CLUSTERS: [OnOff.cluster_id],
        },
        6: {
          # "6": {
          # "profile_id": 104 "device_type": "0x0103",
          # "in_clusters": ["0x0003", "0x0012"]
          # "out_clusters": ["0x0006"]
          # }
          PROFILE_ID: zha.PROFILE_ID,
          DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
          INPUT_CLUSTERS: [Identify.cluster_id, MultistateInput.cluster_id],
          OUTPUT_CLUSTERS: [OnOff.cluster_id],
        },
    },
}    

replacement = RemoteH1DoubleRocker1.replacement
device_automation_triggers = RemoteH1DoubleRocker1.device_automation_triggers

@MarkL1969
Copy link

Thanks!
...
Strange, adding the switch with aktiv quirk now worked - but it used variant 1 with 3 Endpoints!?
Doesn't matter, it's working !!! :o)

One thing I found out about changing operation_mode and click_mode for the 2 rocker switch:

  • If you want to change click_mode, you have to tap 5 times the left button
  • If you want to change operaion_mode, you have to tap 5 times the right button

Otherwise I always got an time out error saying unable to write. Maybe that's of any help for someone ...

@Motorrad-NL
Copy link

Thanks! ... Strange, adding the switch with aktiv quirk now worked - but it used variant 1 with 3 Endpoints!? Doesn't matter, it's working !!! :o)

One thing I found out about changing operation_mode and click_mode for the 2 rocker switch:

  • If you want to change click_mode, you have to tap 5 times the left button
  • If you want to change operaion_mode, you have to tap 5 times the right button

Otherwise I always got an time out error saying unable to write. Maybe that's of any help for someone ...

Can you post the quirk that you are using?

@poughkeepsee
Copy link

poughkeepsee commented Dec 2, 2023

First of all, thank you to everyone that has been contributing to this, your work is outstanding.

A quick tip if someone is unable to make this work. I could not have the device recognize the custom quirk for the life of me, and I also couldn't see the AqaraRemoteManuSpecificCluster, which was making me think something was wrong despite the device being 'correctly' recognized

After about 30 attempts and using different quirk versions, here's what worked for me:

  1. Remove device from network
  2. Add device in ZHA, and click left button once - this is a single click only
  3. Device will be recognized and message will show 'Identifying'
  4. Wait about 1min, only then hold left button for 10sec. Message will now show 'Configuring'
  5. Device will be added and the quirk will be recognized. I used this version

This may have just been pure coincidence, but after hours of trying to add the switch by holding the button for 10sec it was only when I followed the steps above that it started working.

I'm using SkyConnect as the Coordinator.

@petrusb83
Copy link

Hi all,

Okay, so, been reading through this, but it is still not clear to me. So, currently it seems my H1 is in "high speed mode". I want to use it in "multi mode" in ZHA. I tried switching modes by long pressing (above 30s) the left or right button. I also tried pressing the left or right button fast 5 times. No change.

So, is the only way of getting this to work is to use a custom quirk? Like this version

@JaresTech
Copy link

Hi all,

Okay, so, been reading through this, but it is still not clear to me. So, currently it seems my H1 is in "high speed mode". I want to use it in "multi mode" in ZHA. I tried switching modes by long pressing (above 30s) the left or right button. I also tried pressing the left or right button fast 5 times. No change.

So, is the only way of getting this to work is to use a custom quirk? Like this version

Yes it needs to be loading the quirk then you can set the click and operation modes

@petrusb83
Copy link

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

This fixed it!!! Thanks!

@petrusb83
Copy link

Hi all,
Okay, so, been reading through this, but it is still not clear to me. So, currently it seems my H1 is in "high speed mode". I want to use it in "multi mode" in ZHA. I tried switching modes by long pressing (above 30s) the left or right button. I also tried pressing the left or right button fast 5 times. No change.
So, is the only way of getting this to work is to use a custom quirk? Like this version

Yes it needs to be loading the quirk then you can set the click and operation modes

Yeah, got it working now. Thanks. Crazy amout of press combinataion: Single, Double, Tripple & Hold. This works for left, right and both together. Awesome!

@hazzo
Copy link

hazzo commented Dec 6, 2023

Hi guys I'm not able to make it work with my device. This is my 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": "0x0104",
          "device_type": "0x0105",
          "input_clusters": [
            "0x0000",
            "0x0001",
            "0x0003"
          ],
          "output_clusters": [
            "0x0003",
            "0x0006",
            "0x0008",
            "0x0300"
          ]
        },
        "2": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003"
          ],
          "output_clusters": [
            "0x0003",
            "0x0006"
          ]
        },
        "3": {
          "profile_id": "0x0104",
          "device_type": "0x0103",
          "input_clusters": [
            "0x0003"
          ],
          "output_clusters": [
            "0x0006"
          ]
        },
        "4": {
          "profile_id": "",
          "device_type": "",
          "input_clusters": [],
          "output_clusters": []
        },
        "5": {
          "profile_id": "",
          "device_type": "",
          "input_clusters": [],
          "output_clusters": []
        },
        "6": {
          "profile_id": "",
          "device_type": "",
          "input_clusters": [],
          "output_clusters": []
        }
      },
      "manufacturer": "LUMI",
      "model": "lumi.remote.b28ac1"
    }

Thanks!

@UserPiggy
Copy link

Hi folks,
i got a weird one for you. i followed along this guide a few months back with no problems... my double gan is working a treat... i've been expanding my smart home and i picked up another one of the WRS-R02 (H1 wireless double gang switches) but i've been having difficulty getting anf communication from it... when i go to change the cluster, the "AqaraRemoteManuSpecificCluster" dose not show... and after rebooting my home assistant the device changes and i get even fewer options. the device info changes to

unk_model
by unk_manufacturer

The signature is:

"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": "0x0104", "device_type": "0x0105", "input_clusters": [], "output_clusters": [] }, "2": { "profile_id": "0x0104", "device_type": "0x0103", "input_clusters": [], "output_clusters": [] }, "3": { "profile_id": "0x0104", "device_type": "0x0103", "input_clusters": [], "output_clusters": [] } }, "manufacturer": "unk_manufacturer", "model": "unk_model", "class": "zigpy.device.Device" }

and the diagnostics file below:

unk dinostic.txt

any pointers?

@Yarrith
Copy link

Yarrith commented Dec 19, 2023

@UserPiggy
Add following in the quirkfile, had this with a switch myself.

class RemoteH1DoubleRocker5(XiaomiCustomDevice):
    """Aqara H1 Wireless Remote Double Rocker Version WRS-R02, variant 5."""

    signature = {
        MODELS_INFO: [(None, None)],
        ENDPOINTS: {
            1: {
                # "1": {
                #   "profile_id": 260, "device_type": "0x0105",
                #   "in_clusters": [],
                #   "out_clusters": [] }
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [],
            },
            2: {
                # "2": {
                #   "profile_id": 260, "device_type": "0x0103",
                #   "in_clusters": [],
                #   "out_clusters": [] },
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [],
            },
            3: {
                # "3": {
                #   "profile_id": 260, "device_type": "0x0103",
                #   "in_clusters": [],
                #   "out_clusters": [] },
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [],
                OUTPUT_CLUSTERS: [],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
                INPUT_CLUSTERS: [
                    BasicCluster,
                    Identify.cluster_id,
                    PowerConfigurationClusterH1Remote,
                    MultistateInputCluster,
                    AqaraRemoteManuSpecificCluster,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                    LevelControl.cluster_id,
                    Color.cluster_id,
                ],
            },
            2: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [
                    Identify.cluster_id,
                    MultistateInputCluster,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                ],
            },
            3: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [
                    Identify.cluster_id,
                    MultistateInputCluster,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                ],
            },
        }
    }
    device_automation_triggers = RemoteH1DoubleRocker1.device_automation_triggers

@UserPiggy
Copy link

@Yarrith ,

thanks for your help buddy.

so, the added code did two things, it made the unk_manufacturer see the cluster but still didn't hear any responses when buttons were pressed... and the switch that was working fine is now acting like the unk_manufacturere was... with no options for cluster....

my solution, I'm just going to go all in on Aqara and pick up one of their hubs lol

thanks again for your help Yarrith...

@TheJulianJES TheJulianJES added the Xiaomi Request/PR regarding a Xiaomi device label Dec 24, 2023
@ionutus
Copy link

ionutus commented Jan 17, 2024

Hi, all,
I also had problems with the second Aqara WRS-R02 I purchased. I was able to integrate the first one with the quirk posted by xuxiaoqiao above (thank you!), and for the second one I supplemented the code with variant 7 and variant 5.
It appears that I made a mistake when copying the code (IndentationError), once corrected the switch was recognised when paired.
I couldn't set the attributes (failed to call service zha....), but the commands appears to be working.

@novcanovak
Copy link

novcanovak commented Jan 21, 2024

Hi, does anyone's switches work via zigbee2mqtt?
They connect with no problem, but then they don't send any signals to the HA. when pressed.
I have single and double rockers. WS-EUK03.

@acovaci
Copy link

acovaci commented Jan 26, 2024

and for the second one I supplemented the code with variant 7 and variant 5.

Could you share your final config? I'm also facing trouble getting a second switch to work :(

@ionutus
Copy link

ionutus commented Jan 27, 2024

aqara_h1_remote.zip
@acovaci here it is. hope it helps.

@Sjobusen
Copy link

Sjobusen commented Mar 1, 2024

aqara_h1_remote.zip @acovaci here it is. hope it helps.

I also hade the problem that I got one working and my other two not, so I added the file you posted with variant 7 and 5 but still the same. :(
The first button I added still works. any suggestions?

@Yarrith
Copy link

Yarrith commented Mar 1, 2024

@Sjobusen could you share the signatures of the non-working devices please? This way it’s easier to see what can be done.

@Sjobusen
Copy link

Sjobusen commented Mar 1, 2024

Now I got one more working , the last one hade a loose contact on the battery side, must have been cold soldered as the pins came off when I touched it :(. The problem was that when I pressed the buttons I got the blue lamp to light up and had change batteries 2 times.
Thx everyone the have been working on the zha_quirk

@bakovari
Copy link

bakovari commented Mar 2, 2024

Hi Everyone,
I also have similar issue with WRS-R02 Aqara H1 remote double rocker.
Few months ago I maneged to integrate a device based on the useful description by @xuxiaoqiao

Now I bought to additional devices and I cannot integrate them. I copied the quirk file from github https://gist.github.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0#file-aqara_h1_remote-py in the custom_zha_quirks folder by wget command and reload/restart the ZHA, but no seccess.
The file name in the folder is 6ed8dcb950f26337218d0507733970a0

The device still "class": "zigpy.device.Device"

Signature info:

{
  "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": "0x0104",
      "device_type": "0x0105",
      "input_clusters": [
        "0x0000",
        "0x0001",
        "0x0003"
      ],
      "output_clusters": [
        "0x0003",
        "0x0006",
        "0x0008",
        "0x0300"
      ]
    },
    "2": {
      "profile_id": "0x0104",
      "device_type": "0x0103",
      "input_clusters": [
        "0x0003"
      ],
      "output_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "3": {
      "profile_id": "0x0104",
      "device_type": "0x0103",
      "input_clusters": [
        "0x0003"
      ],
      "output_clusters": [
        "0x0006"
      ]
    },
    "4": {
      "profile_id": "",
      "device_type": "",
      "input_clusters": [],
      "output_clusters": []
    },
    "5": {
      "profile_id": "",
      "device_type": "",
      "input_clusters": [],
      "output_clusters": []
    },
    "6": {
      "profile_id": "",
      "device_type": "",
      "input_clusters": [],
      "output_clusters": []
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.remote.b28ac1",
  "class": "zigpy.device.Device"
}

In the debug mode I receive error messages like

2024-03-02 10:54:54.537 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.xiaomi.aqara.remote_h1.RemoteH1DoubleRocker2'>
2024-03-02 10:54:54.537 DEBUG (MainThread) [zigpy.quirks.registry] Fail because device_type mismatch on at least one endpoint

aqara_h1_remote.zip
home-assistant_zha_2024-03-02T12-17-41.649Z.zip

I use SkyConnect with PI4

Could you please help me how to progress?

@HitchRait
Copy link

HitchRait commented Mar 7, 2024

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

I've tried all quirks in this issue, but none worked. So I made some changes to class RemoteH1DoubleRocker3(XiaomiCustomDevice) according to my signature - see below both of them.

I am not a programmer, just write simple scripts and it was my fist time dealing with signatures and all the stuff, so... changes I made may not be completely ok, they just work (for now at least) and I welcome further help and suggestions.

class:

class RemoteH1DoubleRocker3(XiaomiCustomDevice):
    """Aqara H1 Wireless Remote Double Rocker Version WRS-R02, variant 3."""

    signature = {
        MODELS_INFO: [(LUMI, "lumi.remote.b28ac1")],
        ENDPOINTS: {
            1: {
                # "1": {
                #   "profile_id": 0x0104, "device_type": "0x0105",
                #   "in_clusters": ["0x0000", "0x0001", "0x0003", "0x0012", "0xfcc0"],
                #   "out_clusters": ["0x0003", "0x0006", "0x0008", "0x0300"] }
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    Identify.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                    LevelControl.cluster_id,
                    Color.cluster_id,
                ],
            },
            2: {
                # "2": {
                #   "profile_id": "0x0104", "device_type": "0x0103",
                #   "in_clusters": ["0x0003", "0x0012"],
                #   "out_clusters": ["0x0003", "0x0006"] },
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [
                    Identify.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                ],
            },
            3: {
                # "3": {
                #   "profile_id": "0x0104", "device_type": "0x0103",
                #   "in_clusters": ["0x0003", "0x0012"],
                #   "out_clusters": ["0x0003", "0x0006"] },
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [Identify.cluster_id],
                OUTPUT_CLUSTERS: [OnOff.cluster_id],
            },
        },
    }
    replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
                INPUT_CLUSTERS: [
                    BasicCluster,
                    Identify.cluster_id,
                    PowerConfigurationClusterH1Remote,
                    MultistateInputCluster,
                    AqaraRemoteManuSpecificCluster,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                    LevelControl.cluster_id,
                    Color.cluster_id,
                ],
            },
            2: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [
                    Identify.cluster_id,
                    MultistateInputCluster,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                ],
            },
            3: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT_SWITCH,
                INPUT_CLUSTERS: [
                    Identify.cluster_id,
                    MultistateInputCluster,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    OnOff.cluster_id,
                ],
            },
        }
    }
    device_automation_triggers = RemoteH1DoubleRocker1.device_automation_triggers

and my 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": "0x0104",
      "device_type": "0x0105",
      "input_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0012",
        "0xfcc0"
      ],
      "output_clusters": [
        "0x0003",
        "0x0006",
        "0x0008",
        "0x0300"
      ]
    },
    "2": {
      "profile_id": "0x0104",
      "device_type": "0x0103",
      "input_clusters": [
        "0x0003",
        "0x0012"
      ],
      "output_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "3": {
      "profile_id": "0x0104",
      "device_type": "0x0103",
      "input_clusters": [
        "0x0003",
        "0x0012"
      ],
      "output_clusters": [
        "0x0003",
        "0x0006"
      ]
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.remote.b28ac1",
  "class": "aqara_h1_remote.RemoteH1DoubleRocker3"
}

@bakovari
Copy link

bakovari commented Mar 7, 2024

Sorry for the stupid question, but how this changes need to be done?
Where can I modify class or use your script?

@HitchRait
Copy link

HitchRait commented Mar 7, 2024

Sorry for the stupid question, but how this changes need to be done? Where can I modify class or use your script?

I compared input_clusters and output_clusters in signature and script and adjusted script accrordingly. But I only changed commented section and have no idea why it worked (it should not)

@alexhk90
Copy link

alexhk90 commented Mar 7, 2024

Hi Everyone, I also have similar issue with WRS-R02 Aqara H1 remote double rocker. Few months ago I maneged to integrate a device based on the useful description by @xuxiaoqiao

Now I bought to additional devices and I cannot integrate them. I copied the quirk file from github https://gist.github.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0#file-aqara_h1_remote-py in the custom_zha_quirks folder by wget command and reload/restart the ZHA, but no seccess. The file name in the folder is 6ed8dcb950f26337218d0507733970a0

Not sure if it makes any difference, but for me the filepath for the custom quirk is:
/config/custom_zha_quirks/aqara_h1_remote.py
(filename for me is aqara_h1_remote.py rather than 6ed8dcb950f26337218d0507733970a0)

With this in configuration.yaml:

zha:
  enable_quirks: true
  custom_quirks_path: custom_zha_quirks

@bakovari
Copy link

bakovari commented Mar 9, 2024

Managed to resolve the.issue.
I had more endpoint (4, 5, 6) in original signature.
I've tried to modify the quirk which was not fully successful, but at least managed to delete the disturbing endpoints. It did not work afterwards, but after removing and adding the device again it could pick-up the quirk file (made by @xuxiaoqiao) properly and now the device works.

@xuxiaoqiao
It would be good to modify the quirk file with these additional endpoints.

Thanks for your work even so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom quirk available A custom quirk is available to solve the issue, but it's not merged in the repo yet Xiaomi Request/PR regarding a Xiaomi device
Projects
None yet
Development

No branches or pull requests