zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
719 stars 663 forks source link

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

Closed pavaroto closed 3 months ago

pavaroto commented 3 years ago

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
    }
}
PaulMofers commented 2 years ago

Yess, that did it, thanks!

PaulMofers commented 2 years ago

This switch has no hold release action?

xuxiaoqiao commented 2 years ago

@PaulMofers i don’t think so. I didn’t see any events when I release the button after long press.

If my memories are correct I don’t think the “release” actually work on zigbee2mqtt either (it seems they fire the release event 4 seconds after long press, regardless of when you actually release).

Actually I don’t think any of the Aqara D1/E1/H1 remotes supports “release” event, given that a 10-second press means factory reset. But correct me if I’m wrong.

PaulMofers commented 2 years ago

I do not have a D1 or E1, but i have a opple and a sensor switch and they both have long press release

griphos commented 2 years ago

@xuxiaoqiao Do you need more testing on the new version of your quirk?

xuxiaoqiao commented 2 years ago

@griphos that would be nice, if you can. Thank you!

griphos commented 2 years ago

@xuxiaoqiao The new version still works fine with my lumi.remote.b28ac1

deify commented 2 years ago

I've received one of the double rocker switches today! I will try to get your quirk up and running the next few days! Nice work and thanks for your efforts 👍

Edit: works perfectly! Regarding the hold event not firing a release event. Did you find any Infos if that should be possible? I've got the device version with 3 different clusters. If you need help debugging something please ping me!

xuxiaoqiao commented 2 years ago

@deify cool, thanks! I’ve spent a good amount of time searching but I’ve never see anyone who said their D1/E1/H1 supports the “release” event. I’m leaning to believe that the hardware doesn’t support such event.

PaulMofers commented 2 years ago

@deify cool, thanks! I’ve spent a good amount of time searching but I’ve never see anyone who said their D1/E1/H1 supports the “release” event. I’m leaning to believe that the hardware doesn’t support such event.

Probably not indeed, these ones can be paired with one of their switches, the other ones have dedicated buttons for pairing.

seblang commented 2 years ago

@xuxiaoqiao

Thank you for your job :-)

I have integrated one h1 and one WRS2 without any issue.

Unfortunatly I have a second WRS2 and it doesn't work with the quirk!

Below the signature from the second one :

{
  "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": "0x0105",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006",
        "0x0008",
        "0x0300"
      ]
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0003"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "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"
}

can you help me please? thank you in advance sebastien

xuxiaoqiao commented 2 years ago

@seblang hmm interesting. Your device has the DEVICE_TYPE of zha.DeviceType.COLOR_DIMMER_SWITCH (0x0105), for other devices it's zha.DeviceType.ON_OFF_LIGHT_SWITCH (0x0103) . I suspect there may be other differences as well. So could you test all click_mode and operation_mode combinations and tell me if they work or not. And tell me if the zha_event data appears to be different.

Try https://gist.github.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0#file-aqara_h1_remote-py

xuxiaoqiao commented 2 years ago

@seblang Hey, does it work?

Yarrith commented 2 years ago

@seblang Had the same issue, for me what solved it was adding empty endpoints to the RemoteH1DoubleRocker3 class (the last one starting on line 293 of the aqara_h1_remote.py) as the log showed me it was looking for a quirk with {1,2,3,4,5,6} endpoints even though the last three are empty in the device signature.

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": 260, "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": 260, "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": 260, "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: {},
            5: {},
            6: {},
        },
    }
    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
Yarrith commented 2 years ago

@xuxiaoqiao zha_event data seems to be exactly the same just did some testing in all the modes. Only thing is (don't know if this is normal behaviour) every time I reboot home assistant it seems to drop the quirk for some reason. Will try to look at some logs to see what is happening there and if I can figure it out, only a minor inconvenience compared to not having the switch work at all.

Thanks for your work by the way! Really helped me out here.

xuxiaoqiao commented 2 years ago

Thank you @Yarrith for the feedback!!

every time I reboot home assistant it seems to drop the quirk for some reason

This is definitely not normal. But right now I cannot think of any potential reason or fix for that.

I’m just wondering, if it’s dropped after the reboot, how do you load the quirk later?

Yarrith commented 2 years ago

@xuxiaoqiao I remove the device in ZHA (the device is reset to its non useable default state when rebooted, as it was before the quirk loaded), if I then add it again it picks up the quirk and the switch keeps working until the next reboot. If I have some more time I’ll try to look for a reason why it does this in the logs.

Yarrith commented 2 years ago

@xuxiaoqiao Ok upon checking the logs after reboot it reinitialises as an unknown device for some reason, I've gathered the relevant lines I could find. It gets the unk_manufacturer and unk_model for some reason and sends None as the manufacturer and model in its signature as far as I can see? Not sure why or how to solve it. If I then remove this device and add it again the quirk loads correctly. It is a little annoying since I have to change the operating mode again and remove/redo all relevant automations since they don't work anymore.

2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.gateway] [0x62F0](unk_manufacturer unk_model) restored as 'available', last seen: 0:31:28 ago, consider_unavailable_time: 21600 seconds
2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.discovery] 'button' component -> 'ZHAIdentifyButton' using ['identify']
2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.discovery] 'sensor' component -> 'RSSISensor' using ['basic']
2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.discovery] 'sensor' component -> 'LQISensor' using ['basic']

2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x62F0](unk_model): started initialization
2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x62F0:ZDO](unk_model): 'async_initialize' stage succeeded
2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x62F0](unk_model): power source: Battery or Unknown
2022-02-25 09:19:28 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x62F0](unk_model): completed initialization
2022-02-25 09:21:41 DEBUG (MainThread) [zigpy.application] Received frame on uninitialized device <Device model=None manuf=None nwk=0x62F0 ieee=54:ef:44:10:00:1b:0d:6f is_initialized=False> from ep 0 to ep 0, cluster 32772: b'\x1f\x83\xf0b\x00'

2022-02-25 09:21:42 DEBUG (MainThread) [zigpy.device] Ignoring message (b'1c5f11020af700412e0121640c0328190421a80105218b0006240400000000082115010a2100000c20016420016620036720016821a800') on cluster 64704: unknown endpoint or cluster id: 'No cluster ID 0xfcc0 on (54:ef:44:10:00:1b:0d:6f, 1)'

Later on after removing and reconnecting I can see that the 0x62F0 identifier is linked to this device:

2022-02-25 09:21:42 DEBUG (MainThread) [zigpy.application] Device is initialized <Device model='lumi.remote.b28ac1' manuf='LUMI' nwk=0x62F0 ieee=54:ef:44:10:00:1b:0d:6f is_initialized=True>
Yarrith commented 2 years ago

@xuxiaoqiao Well, today it got even weirder, I rebooted and tried to repair the switch and it had a different signature, had to add the following code for it to work:

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

    signature = {
        MODELS_INFO: [(LUMI, "lumi.remote.b28ac1")],
        ENDPOINTS: {
            1: {
                # "1": {
                #   "profile_id": 260, "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": 260, "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": 260, "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": 260, "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,
                    MultistateInputCluster,
                ],
                OUTPUT_CLUSTERS: [OnOff.cluster_id],
            },
            5: {
                # "5": {
                #   "profile_id": 260, "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,
                    MultistateInputCluster,
                ],
                OUTPUT_CLUSTERS: [OnOff.cluster_id],
            },
            6: {
                # "6": {
                #   "profile_id": 260, "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,
                    MultistateInputCluster,
                ],
                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

Still working to solve this rebooting issue but well, in the meantime if anyone else needs the code at least it's here.

Yarrith commented 2 years ago

Here we go, quirk for after reboot, it's really weird but it works:

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

Do check your automations though, because it changes the name of the switch to unk_manufacturer unk_model, might have to change that but once that's done it seems to work permanently.

xuxiaoqiao commented 2 years ago

@Yarrith Thank you so much for the added details!! I'm sure it will help other people in future. I'm not familiar enough with the zigbee stack to understand why it's being so weird. But good to know you at least have a workaround 😿.

Which zigbee stick are you using? Asking this because some Aqara devices (for example, E1 door sensor) only expose full functionality with Aqara hubs (or other zigbee sticks that pretend to be an Aqara hub, like the conbee 2 with recent firmware). I don't know if that's the case.

Yarrith commented 2 years ago

@xuxiaoqiao Don't know why it's this weird either, but might indeed be that it only exposes its functionality when reset somehow? And when you reboot home assistant without performing a reset on the switch it doesn't expose any functionality except a couple buttons with no function it seems, which I then have to reassign in the quirk. I'm using a popp zigbee stick (https://www.popp.eu/zb-stick/#), something I found in a local shop. Anyway I'm glad I got it working and hope other people can use these quirks too if they notice this behaviour.

Fr3n3z1 commented 2 years ago

Hy Guys,

@xuxiaoqiao , Thank you for job and for take time to help us... I have some difficulties to integrate the H1 (doublerocker) switch (WRS-R02).

Step1 to step 4 : it's OK Step5 : i dont not see the "aqara_h1_remote.RemoteH1DoubleRocker" in device info section :-( Step6 : I did it but no change

I have Aqara Hub M2 (EU) with some accessories (motion sensor, door sensor), i use HomeKit Accesories integration in HomeAssistant.

I dont use HomeKit App on phone, i added manually my accessoiries (3 pushs on Hub button and i press 5 secondes on accessory for add them)

Thank you for help

xuxiaoqiao commented 2 years ago

@Fr3n3z1 can you send me your zigbee device signature? There's a 'Zigbee Device Signature' button in the Aqara H1 device view in HA. An example would be something like https://github.com/zigpy/zha-device-handlers/issues/940#issuecomment-1030834077

Fr3n3z1 commented 2 years ago

Hi @xuxiaoqiao. Thank you for the quick reply.

Sorry but I can't find the ZigBee device signature. In the device properties, I only have this:

image

I feel like I must be missing something.

I specify that I have no integration of the type: zigbee2mqtt, no USB Conbee, no deCONZ... nothing of this kind.

Is that the problem?

My installation is very simple: Home assistant + Aqara Hub M2, and I use the HomeKit in HA integration to connect the devices.

Can you help me, I'm a newbie.

Thank u.

dmulcahey commented 2 years ago

Hi @xuxiaoqiao. Thank you for the quick reply.

Sorry but I can't find the ZigBee device signature. In the device properties, I only have this:

image

I feel like I must be missing something.

I specify that I have no integration of the type: zigbee2mqtt, no USB Conbee, no deCONZ... nothing of this kind.

Is that the problem?

My installation is very simple: Home assistant + Aqara Hub M2, and I use the HomeKit in HA integration to connect the devices.

Can you help me, I'm a newbie.

Thank u.

You aren’t using ZHA right? If so, nothing done here will help you. Based on your screenshot it appears you’re using the Aqara integration

Fr3n3z1 commented 2 years ago

Hi @xuxiaoqiao. Thank you for the quick reply. Sorry but I can't find the ZigBee device signature. In the device properties, I only have this: image I feel like I must be missing something. I specify that I have no integration of the type: zigbee2mqtt, no USB Conbee, no deCONZ... nothing of this kind. Is that the problem? My installation is very simple: Home assistant + Aqara Hub M2, and I use the HomeKit in HA integration to connect the devices. Can you help me, I'm a newbie. Thank u.

You aren’t using ZHA right? If so, nothing done here will help you. Based on your screenshot it appears you’re using the Aqara integration

Thk u dmulcahey for infos... I will look to buy USB conBEE II and install ZHA to manage Aqara devices. Thx

Yarrith commented 2 years ago

@Fr3n3z1 The switch should work in the aqara integration, you can find the documentation here https://www.home-assistant.io/integrations/xiaomi_aqara/ However it seems the aqara hub v2 doesn’t play wel with Home Assistant so if you have a v2 hub that might be the issue.

Fr3n3z1 commented 2 years ago

@Fr3n3z1 The switch should work in the aqara integration, you can find the documentation here https://www.home-assistant.io/integrations/xiaomi_aqara/ However it seems the aqara hub v2 doesn’t play wel with Home Assistant so if you have a v2 hub that might be the issue.

@Yarrith, yes I had already seen this link and some opinions on various forums. Many people advised going through homekit integration or flashing the aqara hub. I think it will be easier with USB Conbee and ZHA. Thank you

xuxiaoqiao commented 2 years ago

+1 to the comments above.

It seems that you are using HA + HomeKit Controller + Aqara M2 hub, right? In that case, I'm not familiar with that software stack, my setup is totally different, so i cannot give you any good advice. :(

According to the HA HomeKit controller doc, they support 'stateless switches and sensors' via device automation.Does it work for you? https://www.home-assistant.io/integrations/homekit_controller/#stateless-switches-and-sensors . To be honest I'm surprised if they don't work.

(Side question: If you forget about HA, and pair M2 to your iOS HomeKit. in that case does the H1 wireless button work in your HomeKit? I assume the answer is yes?)

The second approach is using https://www.home-assistant.io/integrations/xiaomi_aqara/ , but I don't think it works in your case. I've heard that integration doesn't work nicely with newer Aqara Hubs (e.g M2).

The third approach is what I'm using: HA + (ZHA integration or zigbee2mqtt) + conbee 2 stick. It's not perfect (some new Aqara devices don't have a device handler yet, plus it seems aqara is moving away from standard zigbee protocol). Personally I'm fine and happy to contribute to it.

Fr3n3z1 commented 2 years ago

@xuxiaoqiao

Wow Wow Wow !!!

Perfect it works with HA automation. It was so simple and yet I missed it. i'm a big shit ;-)

Thank u very much guy!

randyjc commented 2 years ago

If u use the quirk above, be aware when you upgrade to 2022.04. It’ll break it.

Logger: homeassistant.config_entries
Source: custom_zha_quirks/aqara_h1_remote.py:55 
First occurred: 6:47:42 AM (1 occurrences) 
Last logged: 6:47:42 AM

Error setting up entry ConBee II - /dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2482637-if00, s/n: DE2482637 - dresden elektronik ingenieurtechnik GmbH - 1CF1:0030 for zha
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 99, in async_setup_entry
    setup_quirks(config)
  File "/usr/local/lib/python3.9/site-packages/zhaquirks/__init__.py", line 409, in setup
    importer.find_module(modname).load_module(modname)
  File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1029, in load_module
  File "<frozen importlib._bootstrap_external>", line 854, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_zha_quirks/aqara_h1_remote.py", line 55, in <module>
    class AqaraRemoteManuSpecificCluster(XiaomiAqaraE1Cluster):
  File "/usr/local/lib/python3.9/site-packages/zigpy/zcl/__init__.py", line 91, in __init_subclass__
    raise TypeError(
TypeError: `manufacturer_attributes` is deprecated. Copy the parent class's `attributes` dictionary and update it with your manufacturer-specific `attributes`. Make sure to specify that it is manufacturer-specific through the  appropriate constructor or tuple!
Yarrith commented 2 years ago

@randyjc simple fix though, the code on line 55 should no longer be manufacturer_attributes but just attributes. Change this, save, restart HA and it should work, let me know how this goes. Here is the complete class on line 55 for copy-paste:

class AqaraRemoteManuSpecificCluster(XiaomiAqaraE1Cluster):
    """Aqara manufacturer specific settings."""

    ep_attribute = "aqara_cluster"

    # manufacture override code: 4447 (0x115f)
    # to get/set these attributes, you might need to click the button 5 times
    # quickly.
    attributes = {
        # operation_mode:
        # 0 means "command" mode.
        # 1 means "event" mode.
        0x0009: ("operation_mode", t.uint8_t),
        # click_mode:
        # 1 means single click mode, which is low latency (50ms) but only sends
        #   single click events.
        # 2 means multiple click mode, which has a slightly higher latency but
        #   supports single/double/triple click and long press.
        # default value after factory reset: 1.
        0x0125: ("click_mode", t.uint8_t),
    }
randyjc commented 2 years ago

oh wow, it was that simple... it works again. Thanks this saved me like 300 dollars

xuxiaoqiao commented 2 years ago

Thank you for bringing this up! I’ll take a look this weekend and update the file.

xuxiaoqiao commented 2 years ago

Hi all, I updated the https://gist.github.com/xuxiaoqiao/6ed8dcb950f26337218d0507733970a0#file-aqara_h1_remote-py so it should work now. Sorry for the delay, got crazy busy last week.

Actually I've already pushed a change to zha-custom-handlers in the past. so people should not need to actually download this custom quirk (or at least I hope so).

Also, question for all the people using this custom_quirk: which variant are you actually using? I lost track of which variants in the gist are verified to work and which ones are not tested... If I got the reliable list I'll push a PR to the upstream so people don't need to use custom_zha_quirks again...

Yarrith commented 2 years ago

Here’s what I found on my switch (a double rocker one), article no.: WRS-R02 Model: WXKG02LM SKU: AR009GLW02.

xuxiaoqiao commented 2 years ago

@Yarrith ty! So we already have 5 quirks - RemoteH1DoubleRocker[1-5], which one of them are you (and also other people) using exactly?

Yarrith commented 2 years ago

@xuxiaoqiao Right, well I’m using the modified one I posted above so it’s technically not in the quirk you are maintaining since I needed the empty endpoints for it to work:

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

    signature = {
        MODELS_INFO: [(LUMI, "lumi.remote.b28ac1")],
        ENDPOINTS: {
            1: {
                # "1": {
                #   "profile_id": 260, "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": 260, "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": 260, "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: {},
            5: {},
            6: {},
        },
    }
    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

When I reboot ha the switch changes its signature for some reason so then I use the third piece of code I posted above.

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

So technically it’s not compatible yet.

Ditskys commented 2 years ago

@Yarrith ty! So we already have 5 quirks - RemoteH1DoubleRocker[1-5], which one of them are you (and also other people) using exactly?

I'm using your latest and it works perfectly 😊

soaresrm commented 2 years ago

@Yarrith

using your last one with this blueprint https://tagmerge.com/gist/50972e21cb79c649c9a505000498ece0 and finally I have it working

ngmartins commented 2 years ago

Hello all, I carefully read the entire thread and I tried all the mentioned quirk versions, but I wasn't able to get Quirk: aqara_h1_remote.RemoteH1DoubleRocker under the device info section.

I think my device signature is a little bit different:

{
  "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=4151, maximum_buffer_size=127, maximum_incoming_transfer_size=100, server_mask=0, 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": "0x0006",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0002",
        "0x0003",
        "0x0012",
        "0x0019",
        "0xffff"
      ],
      "out_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0012",
        "0x0019",
        "0xffff"
      ]
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x0006",
      "in_clusters": [
        "0x0003",
        "0x0012"
      ],
      "out_clusters": [

        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0012"
      ]
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0006",
      "in_clusters": [
        "0x0003",
        "0x0012"
      ],
      "out_clusters": [
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x000c",
        "0x0012"
      ]
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.sensor_86sw2",
  "class": "zhaquirks.xiaomi.aqara.remote_b286acn01.RemoteB286ACN01"
}

Then I realize my model is also different: WXKG02LM the same one @Yarrith mentioned. However, their quirk does not work for me as well.

Yarrith commented 2 years ago

@ngmartins Your HA seems to load a different zha quirk for this device and the signature is different than mine. Could you check if the currently loaded zha quirk does anything? You can go to developer tools and under events, listen to events type in zha_event, then click start listening and click some buttons on the switch to see if anything happens.

ngmartins commented 2 years ago

Hello again. Out of the box is loading the zhaquirks.xiaomi.aqara.remote_b286a quirk but I would say the entities created make no sense at all. The device is created with the name LUMI lumi.sensor_86sw2 - I do not understand why the sensor part of it,

About your question. The loaded event pressing the key 1:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:55:dd:e7",
        "unique_id": "00:15:8d:00:02:55:dd:e7:1:0x0006",
        "device_id": "45ff087e4b7760d6ea7bb37c94f5e3d7",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 0
        },
        "params": {}
    },
    "origin": "LOCAL",
    "time_fired": "2022-05-30T07:54:07.876907+00:00",
    "context": {
        "id": "018113f53c84a0050532293cf8de354e",
        "parent_id": null,
        "user_id": null
    }
}

and the key 2:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:55:dd:e7",
        "unique_id": "00:15:8d:00:02:55:dd:e7:2:0x0006",
        "device_id": "45ff087e4b7760d6ea7bb37c94f5e3d7",
        "endpoint_id": 2,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 0
        },
        "params": {}
    },
    "origin": "LOCAL",
    "time_fired": "2022-05-30T07:58:12.036714+00:00",
    "context": {
        "id": "018113f8f6443a1ac7ea77220b4efad7",
        "parent_id": null,
        "user_id": null
    }
}

Thanks for your time.

Yarrith commented 2 years ago

Hmmm weird, the signature says the device type is 0x0006 which I cannot find in any zigbee documentation, but it does behave like a switch, I would have to check if we can change this behaviour somehow either through a quirk or maybe configuration (zigbee docs do mention it’s possible to change device type in case of non-compliant hardware). I’ll try to find some more info this weekend so we can try to make your switch useable.

JaresTech commented 2 years ago

I too have the H1 double rocker and a full new install of HA on a HA Blue. The switch pairs as a lumi.remote.b28ac1 and has the same event data on both switches as others say. My questions are:

  1. should the standard ZHA pick up a quirk for this now (all software is up to date)?
  2. If not how do I install the quirks at https://github.com/zigpy/zha-device-handlers?
  3. Where do I see the signature the switch has sent to HA that ZHA is using to match against?
  4. How can I check to see if it should be getting a match?

Below is the Device Signature but I can't see how this marries up to the quirk files

Any help appreciated as I am also new to all this.

Thanks in advance

James

{
  "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": "0x0105",
      "in_clusters": [],
      "out_clusters": []
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [],
      "out_clusters": []
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [],
      "out_clusters": []
    },
    "4": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [],
      "out_clusters": []
    }
  },
  "manufacturer": "unk_manufacturer",
  "model": "unk_model",
  "class": "zigpy.device.Device"
}
ngmartins commented 2 years ago

Hmmm weird, the signature says the device type is 0x0006 which I cannot find in any zigbee documentation, but it does behave like a switch, I would have to check if we can change this behaviour somehow either through a quirk or maybe configuration (zigbee docs do mention it’s possible to change device type in case of non-compliant hardware). I’ll try to find some more info this weekend so we can try to make your switch useable.

Hello,

I appreciate your help: Thanks very much. This is my very first experience with Zigbee. But I do not mind to get my hands dirty. Feel free to share all documentation you think may be interesting.

xuxiaoqiao commented 2 years ago

Thanks @Yarrith so much for the help. I'll also try to help this weekend. Sry for my delayed response --- got way too many interrupts recently 🥲

RoccoDevs commented 2 years ago

I can't seem to change the operation/click modes. No matter what combination I do I get the following event:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "54:ef:44:10:00:38:cd:7a",
        "unique_id": "54:ef:44:10:00:38:cd:7a:1:0x0006",
        "device_id": "b94c62c6dd074f13eca927ad731ed406",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": [],
        "params": {}
    },
    "origin": "LOCAL",
    "time_fired": "2022-06-03T19:22:32.718148+00:00",
    "context": {
        "id": "01G4NG9VWE21G6CJH2RZ99G746",
        "parent_id": null,
        "user_id": null
    }
}

The device signature is as follows:

{
  "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",
        "0x0012",
        "0xfcc0"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0003",
        "0x0012"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0103",
      "in_clusters": [
        "0x0003",
        "0x0012"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006"
      ]
    }
  },
  "manufacturer": "LUMI",
  "model": "lumi.remote.b28ac1",
  "class": "zhaquirks.xiaomi.aqara.remote_h1.RemoteH1DoubleRocker1"
}
Yarrith commented 2 years ago

@JaresTech You have the same special case switch as me that sends None as your manufacturer and model when you reboot with the switch paired, I doubt this has been added to the official code as this is a special case. You'll need the quirk I put in this thread (see below) and install it in /config/zhaquirks/aqara_h1_remote.py (you can create the folders and files that don't exist yet). You also have to add the following to your /config/configuration.yaml:

zha:
    enable_quirks: True
    custom_quirks_path: zhaquirks

This should then work, if you still want to check what quirks are loaded you have to add the following to configuration.yaml:

logger:
    default: warn
    logs:
        homeassistant.components.zha: debug
        bellows.ezsp: debug
        bellows.uart: debug
        zigpy.zdo: debug
        zigpy.application: debug

You can then check this in /config/home-assistant.log.

Here's the code for the quirk: https://gist.github.com/Yarrith/7b87e2068da25b3c1bcf1bc9999b5653

edit: After doing this don't forget to reboot HA ;-)