I was quite enthusiast with that implementation on the Z2M side and I was eager to make the switch from “state / _action” to events with version 2.0. However, it’s way too convoluted to implement it in HA.
This kind of automation where I can intuitively map different button presses, as different triggers, to one or more actions with choice become overly complicated with templates with this system.
triggers:
- entity_id:
- sensor.entree_bouton_aqara_gache_portillon_et_garage_action
to: single
id: portillon
trigger: state
- entity_id:
- sensor.entree_bouton_aqara_gache_portillon_et_garage_action
to: double
id: portillon
trigger: state
- entity_id:
- sensor.entree_bouton_aqara_gache_portillon_et_garage_action
to: hold
id: garage
trigger: state
With to: ~ / null
, you also have the issue of having your automation seen as triggered even when it will not match anything in the end (and it could happen when coming back from unavailable
also).
The implementation of Deconz with events sent on the bus was more intuitive than that.
trigger:
- platform: event
event_type: deconz_event
event_data:
unique_id: 00:17:88:01:06:06:81:5c # Stable ID that does not change like the HA device ID
event: 1002 # Click (xxx2) on left button (1xxx)
Why not sending the “button events” (“button” for disambiguation) on the event bus with a event
event_type
that would contain the “button event” in the event_data
?
trigger:
- platform: event
event_type: event
event_data:
entity_id: event.entree_bouton_aqara_gache_portillon_et_garage_action
event_type: "click"
I don’t think that would be worse than the official solution which has “state” for a stateless thing 3 times:
triggers:
- trigger: state
entity_id: event.hue_remote_control
actions:
- alias: "Choose an action based on the type of event"
choose:
- conditions:
- alias: "Normal evening scene if the button was pressed"
condition: state
entity_id: event.hue_remote_control_on_button
attribute: "event_type"
state: "short_release"
sequence:
- scene: scene.living_room_evening
And worse, this does not handle the race condition issue that requires an ugly template (again) to capture the attribute in the context of this specific trigger run.
There is also the lacking implementation of the event details in the logbook discussed here.
Edit:
Actually, maybe it could be already possible to do that with the event bus with something like that (I need to test).
trigger:
- platform: event
event_type: state_changed
event_data:
new_state:
entity_id: event.bureau_julien_bouton_hue_tap_dial_volet_et_lumieres_action
attributes:
event_type: press_release
button: button_1
Edit 2: Not possible because of this (8 years ago).