Generic Switch Event Processing Method

Hi, Home Assistant Team.

We are developing Matter over Thread Devices.
and I’m testing operating with Home Assistant for interoperability.
All products are Matter certified from CSA.
but I have issues with Event Processing in Generic Switch.
Our Generic Switch supports single press, double press, and long press events.
The problem is that when I write automation through events, the same event will not cause a ‘change’ and will not work.

For example, let’s say that the ‘multi_press_1’ event toggles the power of the Light.
When I press the button once and the ‘multi_press_1’ event occurs, the Light turns on,
but when I press the button once again and the ‘multi_press_1’ event occurs, the Light does not turn off.
However, when I press the button twice to generate the ‘multi_press_2’ event,
and then press the button once to generate the ‘multi_press_1’ event, the Light turns off.

Please review.
Thanks.

Sincerly,
Seunghyun Kim

1 Like

Are you using the state of an entity to trigger on?
Buttons was originally not made with a state, since they do not keep on. The state entity for buttons is a relative new thing to help help users that have only used the state machine, but it is not the best solution, because the state machine do not update an entity unless the value is changed.

The old and “more correct” way of handling buttons is though event triggers.
First you need to capture an event of your button press and that is done by opening up the developer tools and select the events tab.
In the listen to events field type * and then in somewhat rapid succession click start listening, click the button the way you want it and then click stop listening.

The * will make you capture all events on the HA event bus, so you will get all kind of events.
Your button press will be somewhere in the list and you will probably have more than one event, so make sure to find them all.

Use the collected events to set up event triggers.