Proper way to handle multi-press buttons/switches?

If you are a coder, it’s best just to process the raw events:

ZHA

You can use a single trigger for all buttons on all switches and all press types:

triggers:
  - trigger: event
    event_type: zha_event
    event_data:
      cluster_id: 6

Zigbee2MQTT

You need one trigger for each action topic:

triggers:
  - trigger: mqtt
    options:
      topic: zigbee2mqtt/Living Entry Scene/action
  - trigger: mqtt
    options:
      topic: zigbee2mqtt/Kitchen Entry Scene/action

Note: It might be possible to simplify that using wildcards, I haven’t bothered messing with that.


This is based on the idea that button presses are an event (may not work for buttons which have a release event). Hence you don’t have to mess with states you can just say, when a button press (event) happens - do something.

There is a bunch of extra code needed to figure out how to process each event, but that is going to be specific to your needs.

Here are some more details: