I am trying to modify an existing automation so that my doorbell plays a different sound depending on whether the Aqara Zigbee button I am using is pressed once, twice, three times etc. The Zigbee events corresponding to each of these can be selected as a trigger in the UI, however if I add a Choose Action then these are not available, only the battery level appears as shown below:
I would like to replicate the above action so that a different mp3 file is played depending on the number of button clicks. I relaise that I can do this in 3 automations but I has hoped this could be done in a single automation using the new Choose Action.
I think this may be due to the fact that ZHA treats these button presses as Events whereas in Zigbee2MQTT a Sensor can be created that changes to a different state based on the number of clicks.
I have no ZigBee devices so probably shouldn’t even be commenting, but…
Does the doorbell button not show up as a separate binary_sensor under entities rather than devices ?
Hi @jivesinger, that’s the way it works in Zigbee2MQTT but in ZHA you only get the battery status as an entity for for these kind of buttons and the presses are detecable as events in automation triggers. This is how it looks in the Integration:
I finally have this figured out by using the HA Developer Tools to listen to “zha_events” in order to determine the syntax that I needed to for the choose condition template (for my Aqara remote button this is trigger.event.data.args.click_type).
The resulting automation that allows multiple button presses to be handled by a single automation is:
Can you do a ‘hold’ action I wonder?
When I listen for holding events on TRADFRI switches, I get a ‘move’ event with numerical values, and then a ‘stop’.
It does not look like the Mija remote button WXKG01LM (https://zigbee.blakadder.com/Xiaomi_WXKG01LM.html) supports a hold action as when a press & hold this gets interpreted as a single press. Looking at the available options for the device as a trigger in an automation it appears that there are 5 click options as shown below:
Until recently I was using the DeConz integration with these XiaoMi Aqara remotes. With that I could use more trigger modes that the 5 mentioned by Jonah1970. A reduced list including these 5 (all identified by an event number) is:
“Turn on” button pressed 1000 remote_button_short_press
“Turn on” button released 1002 remote_button_short_release
“Turn on” button double clicked 1004 remote_button_double_press
“Turn on” button triple clicked 1005 remote_button_triple_press
“Turn on” button quadruple clicked 1006 remote_button_quadruple_press
“Turn on” button quintuple clicked 1010 remote_button_quintuple_press
“Turn on” button continuously pressed 1001 remote_button_long_press
“Turn on” button released after long press 1003 remote_button_long_release
It seems the remotes allow more options than ZHA has implemented.
With DeConz the trigger events are passed on to the HA in a different form: for my automations I could choose between the triggers using e.g. trigger.event.data.event = 1003, which worked well.
I inspected the trigger events in /Developer Tools/Events and found that the format of DeConz events is very different from the (supposedly raw) events in ZHA as shown in Jonah1970’s post. The DeConz integration apparently does some pre-processing on the raw triggers; ZHA apparently works with the raw event data.
I have changed to the ZHA integration because I prefer the direct communication between the Zigbee devices and HA. In the process of rewriting the automations with Zigbee devices I encountered the same problems as the others in this post. I also ended up with the solution of Jonah1970 which appears to work as a good alternative to my earlier DeConz automations.
It is a pity that the ZHA triggers are based on the device_id instead of the names given. These id’s are meaningless and require some bookkeeping tables to connect them with these names. But this would probably require some pre-processing.
A trigger makes a lot of sense, HA now considers the automation valid, but it’s not performing the action. Is there something else I should include in the trigger?
lumi.remote.b1acn01
by unk_manufacturer
Zigbee info
IEEE: 00:15:8d:00:02:8f:44:0e
Nwk: 0x4ec2
Device Type: EndDevice
LQI: 132
RSSI: -67
Last Seen: 2021-08-22T18:03:34
Power Source: Battery or Unknown
Hi, you could go into Developer Tools, type “zha_event”, then click “Start Listening”. You can then observe the log that is produced to see what (if any) events are being captured for your device as in the example below:
I don’t recognise the sensor name “unk_manufacturer” (for mine I see “Lumi” here) so you might want to check the link below to see if you can find it and confirm that it is supported:
The other thing you could do is to go to your list of automations and click “RUN ACTIONS” for the relevant automation. If your light toggles then that proves this part of the automation is working as expected.
Pair the switch in ZHA by holding it down for ten seconds to enter pairing mode, then repeatedly, quickly pressing the button until ZHA sees the device.
Open Developer Tools / Events and under “Listen to event” enter zha_event as “Event to subscribe to” and click “Start listening”
Press the button!
Create an automation with trigger platform: event, event_type: zha_event and event_data contains device_ieee, unique_id and device_id that were shown in the logs once you pressed the button
in my case the automation always performs the single click option even on double and triple press.
Does anyone know why?
when listening to zha_events “double” and “triple” are sent correctly from the switch to HA, so it seems to be an issue with the automation itself.