I got one of the new Aqara action buttons. Got it added to Z2H and the single ‘click’ works great but when I try to use the “long” press (hold/release) I can’t get the automation to trigger. At first I had a single automation but for debugging purposes here is a single single action:
alias: Aqara Switch - Long Hold Turn Off All and Turn On lr_small_light
description: >-
Turns off all lights in the living room and turns on lr_small_light on a long
hold.
triggers:
- entity_id: sensor.aqara_lr_lights_aqara_lr_lights_click
attribute: click
to: hold
trigger: state
conditions: []
actions:
- data:
message: Long hold triggered
level: info
action: system_log.write
- target:
entity_id: switch.livingroom_small_light
action: switch.toggle
data: {}
mode: single
LR Small Light is a tasmota switch (switch.livingroom_small_light).
Looks like the trigger is not triggering as I don’t see the log entry.
Have you read the breaking changes in Z2M 2.0.0 and greater? The link you posted even says that the click event is deprecated and that you should use the action event (which is also not enabled by default in Z2M >2.0)
I’m still on v1 ( Zigbee2MQTT version
1.27.0-dev commit: 36a4754)
This automation works for the “single” click but not for the “hold/release” (what I’m calling long-press):
alias: >-
Aqara Switch - Toggle Lights on Single Click, Turn Off All and Turn On
lr_small_light on Long Press
description: >
Single click toggles all lights in the living room. Long press turns off all
lights and turns on lr_small_light.
triggers:
- entity_id: sensor.aqara_lr_lights_aqara_lr_lights_click
attribute: click
to: single
id: single_click
trigger: state
- entity_id: sensor.aqara_lr_lights_aqara_lr_lights_click
attribute: click
to: hold
id: long_press_hold
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: single_click
sequence:
- action: light.toggle
data: {}
target:
area_id: living_room
- action: switch.toggle
metadata: {}
data: {}
target:
area_id: living_room
- conditions:
- condition: trigger
id: long_press_hold
sequence:
- target:
entity_id: light.lr_small_light
action: light.turn_on
data: {}
mode: single
The single action of this works, working on the “hold”
alias: >-
Aqara Switch - Toggle Lights on Single Click, Turn Off All and Turn On
lr_small_light on Long Press
description: >
Single click toggles all lights in the living room. Long press turns off all
lights and turns on lr_small_light.
triggers:
- entity_id: sensor.aqara_lr_lights_aqara_lr_lights_click
attribute: click
to: single
id: single_click
trigger: state
- entity_id: sensor.aqara_lr_lights_aqara_lr_lights_click
attribute: click
to: hold
id: long_press_hold
trigger: state
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: single_click
sequence:
- action: light.toggle
data: {}
target:
area_id: living_room
- action: switch.toggle
metadata: {}
data: {}
target:
area_id: living_room
- conditions:
- condition: trigger
id: long_press_hold
sequence:
- target:
entity_id: light.lr_small_light
action: light.turn_on
data: {}
mode: single
``
I’m honestly not sure why the single press seems to work. I’m also not sure how exactly to do it using the HA entity, because I don’t use the Z2M HA integration.
But as an alternative, I think you could use an MQTT trigger like this: