Help with Aqara switch/CC2531 Zigbee automations

Hi, I have a pre-flashed CC2531 integrated via zigbee2mqtt and a bunch of zigbee switches and sensors (Xiaomi Button Gen 1, Gen 2, Tradfri switch/dimmer and Aqara Human sensor.

I can get them to control stuff with single click but not anything else. The fact there are two ways to connect (proprietary gateways) and as of HA 0.101 two languages (json and yaml) makes things rather confusing.

I see my switches as sensors (not as binary_sensors as seen in many tutorials for these devices).

How can I make things repond to, say, doubleclicking the Gen 2 button? I do see this in zigbee2mqtt log:

  zigbee2mqtt:info 11/5/2019, 8:12:52 PM MQTT publish: topic 'zigbee2mqtt/0x00158d00044db66f', 
payload '{"battery":100,"voltage":3075,"linkquality":18,"click":"double"}'

I can see the doubleclick and even hold/release are being detected. I tried automations with States, Events and MQTT but the syntax is confusing. I am unable to assign anything else than single click.

Any tips? Thanks!

Edit: I have figured it out. Single and double click is a “click” Event but Hold is an Action event. Action events work via MQTT triggers.

Try setting the debounce on those to (say) half a second, or even a tenth of a second.

I have figured it out. Thanks.

Please post your solution! :slight_smile:

1 Like

It was solved by using a Template condition.

This is for Hold action:

- id: '1572988510200'
  alias: Aqara Hold To Toggle Desk Lamp
  description: ''
  trigger:
  - platform: mqtt
    topic: zigbee2mqtt/Aqara Button
  condition:
  - condition: template
    value_template: '{{ ''hold'' == trigger.payload_json.action }}'
  action:
  - data:
      entity_id: light.desk_lamp
    service: light.toggle

And this is for clicking and doubleclicking:

- id: '1572988064322'
  alias: Aqara Doubleclick to Daylight
  description: ''
  trigger:
  - entity_id: sensor.aqara_button_1_click
    platform: state
    to: double
  condition: []
  action:
  - data:
      brightness_pct: 100
      entity_id: light.living_room_light
    service: light.turn_on
  - data:
      brightness_pct: 100
      entity_id: light.living_room_light_tunable
      kelvin: 5000
    service: light.turn_on
- id: '1572988154355'
  alias: Aqara Single Click to Night Light
  description: doubleclick
  trigger:
  - entity_id: sensor.aqara_button_1_click
    platform: state
    to: single
  condition: []
  action:
  - data:
      brightness_pct: 40
      entity_id: light.living_room_light_tunable
      kelvin: 3000
    service: light.turn_on
  - data:
      entity_id: light.living_room_light
    service: light.turn_off

To my surprise, these both work as toggles - a simple singleclick turns the light off if previously triggered.

1 Like