I'd like to use a long_press on my Voice PE button to trigger an automation. However, button presses only seem to be recognized as state changes, not as singular events. This means if the last button press already was a long_press, the automation doesn't trigger because its state wasn't changed. Only if I single or double press the button (= change its state) and then long_press, I can trigger the automation. Here's the YAML I thought should be working (w/o my ID):
trigger:
- platform: event
event_type: home_assistant_voice_[...]_button_press
event_data:
event_type: long_press
Has anyone else run into this problem and has a solution for me?
That's only kind-of correct... the state was changed, but a trigger focused on the attribute event_type wouldn't fire, because that attribute didn't change.
Instead, use a state-focused State trigger for the event entity, so that the state change fires the trigger. Then add a condition to filter for the press type:
triggers:
- trigger: state
entity_id: event.home_assistant_voice_[...]_button_press
not_to: unavailable
conditions:
- condition: template
value_template: "{{ trigger.to_state.attributes.event_type == 'long_press'}}"
FYI
It looks like "purpose-specific" triggers should be moving from Labs to Core in next month's release (2026.7)... which will include the event.received trigger that handles this issue on it's own, no need for the trigger-condition combination:
trigger: event.received
target:
entity_id: event.home_assistant_voice_[...]_button_press
options:
event_type:
- long_press
Thank you for the explanation! Your solution works beautifully, I really have to look into templates. Great to hear that an overhaul will come.