Hi, I´m using shutter switch H2 EU and Light Switch H2 EU in a thread environment with Home Assistant through the Matter integration. I´m using the non coupled buttons as trigger for automations. As trigger, up to now, only the general change of state and attributes works.
Although the device class of the pysical buttons is button, the press action does not work as trigger. It only changes the timestamp of the event.
The state of the event is basically a timestamp as far as I can see. When pressing the relating button, the timestamp changes and triggers the action.
Nevertheless, and Restart or connection timeout changes the state as well and then undesirably triggers the action.
I would expect that only the button press action could be used as trigger.
Check entity states
Can you check what the current entity states and event types are?
Otherwise, record the entity states while triggering the buttons.
In point 3 in both pictures, you should specify the name of the entity instead of “aqara”.
How it works
I just noticed that it’s the same with my “Aqara Climate Sensor W100.”
The state is the date and time of the last change. But you can check for the event types (on the right side of the image / Rightmost column “Attributes”). Check if it’s the same with your device.
See the last image for details on how it works with automations.
Any status change triggers the event, but then it is checked to see which event triggered it.
- multi_press_1: Button pressed once.
- multi_press_2: button pressed twice.
- long_press: the button is pressed and held.
- long_release = button released after being pressed and held.
If I remember correctly, I didn’t use long_press because it caused problems.
Instead, I used long_release.
And here is the YAML for pressing the button once to turn a lamp on and off:
alias: Lights on/off
description: ""
triggers:
- trigger: state
entity_id:
- event.aqara_climate_sensor_w100_button_2
conditions:
- condition: state
entity_id: event.aqara_climate_sensor_w100_button_2
attribute: event_type
state: multi_press_1
actions:
- type: toggle
device_id: ...
entity_id: ...
domain: light
mode: single
Hi, as event type, only “initial_press” is available.
There´s no other event type available that could be used as additional condition in an automation. It seems that this is not yet (?) fully implemented in thread of Matter maybe.
The automation
alias: Licht EG Garten Einfahrt aus von Ankleide
description: ""
triggers:
- trigger: state
entity_id:
- event.ankleide_schlafzimmer_taste_5
conditions:
- condition: state
entity_id: event.ankleide_schlafzimmer_taste_5
attribute: event_type
state: initial_press
actions:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.ankleide_schlafzimmer_leuchte_1
mode: single
doesn´t work unfortunately.
As you’ve noticed, creating automations with Matter buttons in Home Assistant is such a pain at the moment thanks to how the Event entity models events.
Even if your previous code worked, it will trigger the automation for more reasons than a button press (e.g. when the button goes offline and back online or when Home Assistant is restarted since availability state also triggers a state change).
According to the Matter compliance document looks like Aqara only implemented the single press and didn’t add support for long press or multipress, hence that you only see the initial press event.
Does a restart actually change the timestamp? Or is the state reset to nothing, or is the old timestamp reused? If so, one could try something like this:
condition:
- condition: template
value_template: >
{{ as_timestamp(trigger.to_state.state) | int(0) > (now().timestamp() - 5) }}
You don’t need the condition since the state is ALWAYS initial_press for a button that only has that event, so it will never change. You can remove that block. In fact you never use conditions for buttons, only in the actions section if needed.
You need this for buttons with multiple button press types like the W100, but here it’s not necessary.
What you will need in the triggers is something like this to avoid the automation firing for things that are not a button press:
not_from:
- unknown
- unavailable
not_to:
- unknown
- unavailable
Unfortunately Home Assistant cannot trigger on the actual Matter event, and this Event entity construct is a bit evil.
Edit: Wrong link fixed
Hi, we´ll try these “exclude options” asap. Sounds like a good proposal. I hope that this problem will be fixed with the next Matter upgrades for Home Assistant.
They are aware but looks like it’s easier said than done:
By the way, if, let’s say, Aqara updates the firmware to add support for long press or multi-press, your automation will also trigger because the supported event types will change and that’s an entity state change too ![]()
.
I completely agree. Unfortunately, neither does Home Assistant Switch Manager. It also seems that the developer is not interested in providing this support.
Could it be that the H2 isn’t Matter certified at all? In any case, I can’t find anything in the specs. And I can’t find the Matter logo anywhere.
You could try something like this to prevent the automation from running after a Home Assistant restart:
condition:
- condition: template
value_template: >
{{ as_timestamp(trigger.to_state.state) | int(0) > (now().timestamp() - 5) }}
This condition checks if the timestamp of the triggered state change (the button press) is less than 5 seconds old. After a restart, the entity loads its old, often stale, state (the time of the last actual button press, which could be hours ago). Since the timestamp is old or the state is “unknown” or “unavailable” the automation will not execute the action.
It is, you can check that in the official CSA site. This is for the EU version for instance.
If you download the compliance document it tells you which features it supports for the Switch cluster, which is how Matter models momentary buttons.
Vendors can choose what event to implement, Aqara decided to only implement the initial press which would be the most basic button possible without the fancy long press or multipress. An advantage of initial press is that it triggers as soon as you press the button so automations trigger way faster, without having to wait for the release to detect if it’s a short or long release and without having to wait for more taps if it supports multi-tap.
Aqara could have implemented more events, after all the initial press is mandatory even if you implement the others. Unfortunately again, Home Assistant will hide the initial press event if it detects support for other events, that’s why in the W100 the initial press is not available even if the button is also sending it.
Yes, but then I have a chance to use the condition option to select what to do.






