Automation for ALL buttons

Im slowly adding Zigbee smart switches throughout the home and wanting to be able to use ALL buttons to trigger an ‘emergency mode’ that will turn on every light in the house if there’s a long-press detected. Right now, i have 3 of them working perfect, but it’s a good amount of coding for it. I have a counter set up for tracking if the emergency mode is active or not, letting me cancel it with a short press.

I plan to add another 12 buttons throughout the house, so I’m wondering if there’s an easier way to do the automation for each button without a LOT of copy/paste. Maybe a Blueprint, where i specify the “normal” device the button would operate?

Basically, it would do this:

1 - long-press detected (any button)
2 - set mode counter to 1
3 - save current light scene
4 - turn on all lights
5 - short-press detected (any button)
6 - restore saved scene
7 - set mode counter to 0

I can already do all of those actions from the 3 current buttons. Im just asking about how to do it more easily in the automations.

What kind of trigger are you using to detect a button’s long-press event?

Some triggers allow you to specific a list of entities. If the trigger your using doesn’t support that feature then you can use a trigger that listens for all long-press events along with a condition that confirms the event was produced by one of the desired buttons.

This technique will allow you to use a single automation to handle all buttons.

I assumed that i could do a single “long-press” automation, but was wanting to do a short-press on any button to cancel the Emergency mode. It’s just a preference, but a 2nd long-press can be used to reset the scene & Emergency mode.

The same automation can listen for both events and then perform the appropriate actions depending on which event occurred.