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

[Device Support Request] Xiaomi Aqara E1 double key wireless switch

Open suvl opened this issue 2 years ago • 10 comments

As with zigbee2mqtt I was expecting this Aqara double switch to have at least two actions:

  1. left click
  2. right click
  3. both click

double clicks of the three combinations, I believe, are also supported by the device, but I am not completely sure.

right now, the events that are emitted when the left key is pressed three times are these:

Current press events
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:6e:bb:44",
        "unique_id": "00:15:8d:00:02:6e:bb:44:1:0x0006",
        "device_id": "0e6c85509d0f12d8c35b2fd2c76a8cd7",
        "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-08-11T11:41:30.029367+00:00",
    "context": {
        "id": "01GA6BB8HDMSRAQNS2GM71A8DQ",
        "parent_id": null,
        "user_id": null
    }
},

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:6e:bb:44",
        "unique_id": "00:15:8d:00:02:6e:bb:44:1:0x0006",
        "device_id": "0e6c85509d0f12d8c35b2fd2c76a8cd7",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": 1
        },
        "params": {}
    },
    "origin": "LOCAL",
    "time_fired": "2022-08-11T11:41:30.029005+00:00",
    "context": {
        "id": "01GA6BB8HD4ZKD44ZD6G1MZSKB",
        "parent_id": null,
        "user_id": null
    }
}, 

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:02:6e:bb:44",
        "unique_id": "00:15:8d:00:02:6e:bb:44:1:0x0006",
        "device_id": "0e6c85509d0f12d8c35b2fd2c76a8cd7",
        "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-08-11T11:41:29.251523+00:00",
    "context": {
        "id": "01GA6BB7S37P67WZC4WJ6VDJAF",
        "parent_id": null,
        "user_id": null
    }
}

these are not useful to control anything, I think.

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=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"
}
Diagnostic information
{
  "home_assistant": {
    "installation_type": "Home Assistant Supervised",
    "version": "2022.7.7",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.5",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Lisbon",
    "os_name": "Linux",
    "os_version": "5.15.32-v8+",
    "supervisor": "2022.08.3",
    "host_os": "Debian GNU/Linux 11 (bullseye)",
    "docker_version": "20.10.17",
    "chassis": "",
    "run_as_root": true
  },
  "custom_components": {
    "xiaomi_cloud_map_extractor": {
      "version": "v2.2.0",
      "requirements": [
        "pillow",
        "pybase64",
        "python-miio",
        "requests",
        "pycryptodome"
      ]
    },
    "dwains_dashboard": {
      "version": "2.0.3",
      "requirements": []
    },
    "xiaomi_miot": {
      "version": "0.6.10",
      "requirements": [
        "construct==2.10.56",
        "python-miio>=0.5.6",
        "micloud>=0.3"
      ]
    },
    "hacs": {
      "version": "1.26.2",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    },
    "fontawesome": {
      "version": "2.1.5",
      "requirements": []
    }
  },
  "integration_manifest": {
    "domain": "zha",
    "name": "Zigbee Home Automation",
    "config_flow": true,
    "documentation": "https://www.home-assistant.io/integrations/zha",
    "requirements": [
      "bellows==0.31.1",
      "pyserial==3.5",
      "pyserial-asyncio==0.6",
      "zha-quirks==0.0.77",
      "zigpy-deconz==0.18.0",
      "zigpy==0.47.3",
      "zigpy-xbee==0.15.0",
      "zigpy-zigate==0.9.0",
      "zigpy-znp==0.8.1"
    ],
    "usb": [
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*2652*",
        "known_devices": [
          "slae.sh cc2652rb stick"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*sonoff*plus*",
        "known_devices": [
          "sonoff zigbee dongle plus"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*tubeszb*",
        "known_devices": [
          "TubesZB Coordinator"
        ]
      },
      {
        "vid": "1A86",
        "pid": "7523",
        "description": "*zigstar*",
        "known_devices": [
          "ZigStar Coordinators"
        ]
      },
      {
        "vid": "1CF1",
        "pid": "0030",
        "description": "*conbee*",
        "known_devices": [
          "Conbee II"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8A2A",
        "description": "*zigbee*",
        "known_devices": [
          "Nortek HUSBZB-1"
        ]
      },
      {
        "vid": "0403",
        "pid": "6015",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate+"
        ]
      },
      {
        "vid": "10C4",
        "pid": "EA60",
        "description": "*zigate*",
        "known_devices": [
          "ZiGate"
        ]
      },
      {
        "vid": "10C4",
        "pid": "8B34",
        "description": "*bv 2010/10*",
        "known_devices": [
          "Bitron Video AV2010/10"
        ]
      }
    ],
    "codeowners": [
      "@dmulcahey",
      "@adminiuga"
    ],
    "zeroconf": [
      {
        "type": "_esphomelib._tcp.local.",
        "name": "tube*"
      },
      {
        "type": "_zigate-zigbee-gateway._tcp.local.",
        "name": "*zigate*"
      }
    ],
    "after_dependencies": [
      "onboarding",
      "usb",
      "zeroconf"
    ],
    "iot_class": "local_polling",
    "loggers": [
      "aiosqlite",
      "bellows",
      "crccheck",
      "pure_pcapy3",
      "zhaquirks",
      "zigpy",
      "zigpy_deconz",
      "zigpy_xbee",
      "zigpy_zigate",
      "zigpy_znp"
    ],
    "is_built_in": true
  },
  "data": {
    "ieee": "**REDACTED**",
    "nwk": 18538,
    "manufacturer": "LUMI",
    "model": "lumi.sensor_86sw2",
    "name": "LUMI lumi.sensor_86sw2",
    "quirk_applied": true,
    "quirk_class": "zhaquirks.xiaomi.aqara.remote_b286acn01.RemoteB286ACN01",
    "manufacturer_code": 4151,
    "power_source": "Battery or Unknown",
    "lqi": 98,
    "rssi": null,
    "last_seen": "2022-08-11T12:41:30",
    "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=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"
          ]
        }
      }
    },
    "entities": [
      {
        "entity_id": "button.lumi_lumi_sensor_86sw2_identify",
        "name": "LUMI lumi.sensor_86sw2"
      },
      {
        "entity_id": "sensor.lumi_lumi_sensor_86sw2_power",
        "name": "LUMI lumi.sensor_86sw2"
      },
      {
        "entity_id": "sensor.lumi_lumi_sensor_86sw2_device_temperature",
        "name": "LUMI lumi.sensor_86sw2"
      }
    ],
    "neighbors": [],
    "endpoint_names": [
      {
        "name": "REMOTE_CONTROL"
      },
      {
        "name": "REMOTE_CONTROL"
      },
      {
        "name": "REMOTE_CONTROL"
      }
    ],
    "user_given_name": "clickTV",
    "device_reg_id": "0e6c85509d0f12d8c35b2fd2c76a8cd7",
    "area_id": "4305f4ac56f64d9cbd68b12fdd7ca645",
    "cluster_details": {
      "1": {
        "device_type": {
          "name": "REMOTE_CONTROL",
          "id": 6
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {
              "0x0004": {
                "attribute_name": "manufacturer",
                "value": "LUMI"
              },
              "0x0005": {
                "attribute_name": "model",
                "value": "lumi.sensor_86sw2"
              }
            },
            "unsupported_attributes": {}
          },
          "0x0001": {
            "endpoint_attribute": "power",
            "attributes": {
              "0x0020": {
                "attribute_name": "battery_voltage",
                "value": 32.2
              },
              "0x0021": {
                "attribute_name": "battery_percentage_remaining",
                "value": 200
              }
            },
            "unsupported_attributes": {}
          },
          "0x0002": {
            "endpoint_attribute": "device_temperature",
            "attributes": {
              "0x0000": {
                "attribute_name": "current_temperature",
                "value": 3000
              }
            },
            "unsupported_attributes": {}
          },
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xffff": {
            "endpoint_attribute": "manufacturer_specific",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0012": {
            "endpoint_attribute": "multistate_input",
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0000": {
            "endpoint_attribute": "basic",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0019": {
            "endpoint_attribute": "ota",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0xffff": {
            "endpoint_attribute": "manufacturer_specific",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0012": {
            "endpoint_attribute": "multistate_input",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0006": {
            "endpoint_attribute": "on_off",
            "attributes": {
              "0x0000": {
                "attribute_name": "on_off",
                "value": 0
              }
            },
            "unsupported_attributes": {}
          }
        }
      },
      "2": {
        "device_type": {
          "name": "REMOTE_CONTROL",
          "id": 6
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0012": {
            "endpoint_attribute": "multistate_input",
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0012": {
            "endpoint_attribute": "multistate_input",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0006": {
            "endpoint_attribute": "on_off",
            "attributes": {
              "0x0000": {
                "attribute_name": "on_off",
                "value": 0
              }
            },
            "unsupported_attributes": {}
          }
        }
      },
      "3": {
        "device_type": {
          "name": "REMOTE_CONTROL",
          "id": 6
        },
        "profile_id": 260,
        "in_clusters": {
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0012": {
            "endpoint_attribute": "multistate_input",
            "attributes": {},
            "unsupported_attributes": {}
          }
        },
        "out_clusters": {
          "0x0003": {
            "endpoint_attribute": "identify",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0004": {
            "endpoint_attribute": "groups",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0005": {
            "endpoint_attribute": "scenes",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x000c": {
            "endpoint_attribute": "analog_input",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0012": {
            "endpoint_attribute": "multistate_input",
            "attributes": {},
            "unsupported_attributes": {}
          },
          "0x0006": {
            "endpoint_attribute": "on_off",
            "attributes": {
              "0x0000": {
                "attribute_name": "on_off",
                "value": 0
              }
            },
            "unsupported_attributes": {}
          }
        }
      }
    }
  }
}

Additional context Link to the zigbee2mqtt implementation: here.

suvl avatar Aug 11 '22 11:08 suvl

According to the code, this device supports short, long and double press for left, right and both: https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/xiaomi/aqara/remote_b286acn01.py#L214..L224

What are the events that you miss? Have you looked at the automations available for that device? It seems that the device already implement it and you don't have to handle the events.

javicalle avatar Aug 18 '22 09:08 javicalle

@javicalle as you can see from the issue, all I get event wise when I click any of the two buttons are these attribute_updated events image it won't even tell me what button was pressed.

tell you what, I'm going to reconfigure the device to see if it was a bad interview.

suvl avatar Aug 18 '22 09:08 suvl

@javicalle OOTB with zigbee2mqtt I get an MQTT event that tells me what button was pressed: left, right or both. Trying to replicate that with ZHA.

I was able to replicate the same behaviour with this trigger:

  - platform: event
    event_type: zha_event
    event_data:
      device_id: 0e6c85509d0f12d8c35b2fd2c76a8cd7
      endpoint_id: 1
      args:
        value: 1

For what I understand from the code, this event should be mapped to the following one:

  - device_id: 0e6c85509d0f12d8c35b2fd2c76a8cd7
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: button_1

but this event is never triggered.

suvl avatar Aug 18 '22 10:08 suvl

Every rocker button will send events from a diferent "endpoint_id": 1/2/3,. Not sure about how diferent actions must come, I believe that would be as diferent "command".

But ill will be much better handle it from the device event and not as a zha_event: image

From the automation view:

  • 'Trigger type': device
  • select your device
  • in the 'trigger' combo you must see all the available events for the device

javicalle avatar Aug 18 '22 11:08 javicalle

@javicalle I agree with you however what I was trying to tell you is that despite there being a zha_event being triggered there is no device event from the zha platform that is being triggered. I've tried to listen to all events and do not see anything other than the zha_event being triggered. So using the device trigger type is not working.

suvl avatar Aug 18 '22 12:08 suvl

I see. You are having only events from the OnOff cluster and nothing from the MultistateInputCluster. I don't know if there's a way to activate this (I don't see anything in the code).

Can you enable the debug logs and look for anything related to the device?

javicalle avatar Aug 18 '22 12:08 javicalle

According to blackadder and Z2M this device only reports single_click events:

  • https://zigbee.blakadder.com/Aqara_WXKG02LM.html
  • https://www.zigbee2mqtt.io/devices/WXKG02LM_rev1.html#action-enum

You can identify the different buttons from the endpoint_id.

javicalle avatar Aug 18 '22 16:08 javicalle

Same isue for me. Please add the support of this devixce. I have attached my log file. my device is cold "lumi.remote.acn004" If you need more information i can make more logs, but i do not know how to make them. home-assistant.log

DeadlySin2 avatar Sep 28 '22 16:09 DeadlySin2

@DeadlySin2 your device don't have the same signature. Please open another issue with all the information.

javicalle avatar Sep 28 '22 19:09 javicalle

I'm also having problems with this device (lumi.sensor_86sw2). There are two versions of the device, this is the original 2016 model, I understand the 2018 model identifies as lumi.remote.b286acn02 and I believe there are hardware differences in the way that they function, however in ZHA they are both using the same quirk.

The info scattered around the web suggests that the later version supports double-press and hold events, so there's clearly a difference somehow that the quirk is not directly addressing, and that it is necessary to configure the device via Zigbee command using a manufacturer-specific endpoint to change the 'operation mode' (I'm unsure as lots of the discussion online also mixes with the H1 devices, e.g. https://github.com/zigpy/zha-device-handlers/issues/940). Again the quirk does not do anything to expose this change of mode. Apparently zigbee2mqtt exposes a YAML configuration option to disable 'legacy mode' for some devices?

Like you, I am just getting attribute updated events from endpoints 1 and 2 on the OnOff cluster (cluster ID 6). The 'both press' event doesn't fire from endpoint 3 either. This suggests to me that the device is running in ZLL (sometimes referred to as LO) mode instead of ZHA mode which perhaps the quirk expects. Except the problem is, I'm not completely sure that both versions of the hardware work the same way in this regard, and even though the device exposes a manufacturer specific cluster on endpoint 1 (0xffff), it does not list any attributes so I do not know how or what to send as a command to change it. The cluster details mentioned for the H1 version don't match what I see exposed for this device.

andyjenkinson avatar Oct 09 '22 10:10 andyjenkinson

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 07 '23 11:04 github-actions[bot]