I want to write an automation using the actions of my Ikea light switch that connected using Zigbee2MQTT.
I learned that I define a trigger like so for the on action (I believe this is from the MQTT device trigger integration ):
domain: mqtt
device_id: 920adb62963188b3da89dff27d06513e
type: action
subtype: "on"
trigger: device
enabled: true
However, I would like to have a generic trigger that will trigger on any action. So something like this (which does not work):
domain: mqtt
device_id: 920adb62963188b3da89dff27d06513e
type: action
subtype: "any"
trigger: device
enabled: true
I would then like to use conditions on the trigger object to select the corresponding action. So something like this pseudo-code:
if trigger.subtype == "on":
perform_on_action()
elif trigger.subtype == "off":
perform_off_action()
elif trigger.subtype == "left":
perform_color_change_action()
...
Is this possible and how would I achieve this?
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
February 16, 2026, 10:07pm
2
Device_id’s don’t use templates, and pasting in a word like “any” if it’s not one of the specific words it’s looking for will not work.
You can probably do it with it’s entity_id, however. Trigger on state and don’t tell it what state, then use the trigger variables to see what the trigger was.
123
(Taras)
February 16, 2026, 11:33pm
3
What you want is possible if you use a State Trigger to monitor the device’s Event entity.
The new Zigbee2MQTT 2.0 introduces the new event based actions for things with buttons. And at the same time deprecates the old way of using action sensors.
Note that you enable these new actions by setting the Zigbee2MQTT configuration “Home Assistant experimental event entities” to enabled (true)
However, it seems the Zigbee2MQTT devs have pulled back on the plan to remove the legacy sensor based method, so for now users can start to play with the events but it may be best to keep things as …
It will look something like this:
alias: Example
triggers:
- trigger: state
entity_id: event.your_device_action
not_from: unavailable
not_to: unavailable
conditions: []
actions:
- variables:
btn_evnt: "{{ trigger.to_state.attributes.event_type }}"
- choose:
- conditions: "{{ btn_evnt == 'on' }}"
sequence:
... actions to perform when button event is `on` ...
- conditions: "{{ btn_evnt == 'off' }}"
sequence:
... actions to perform when button event is `off` ...
- conditions: "{{ btn_evnt == 'left' }}"
sequence:
... actions to perform when button event is `left` ...
An alternative is to use an MQTT Trigger to monitor the device’s MQTT topic.
dtrott
(David Trott)
February 18, 2026, 9:49am
4
I use Tuya/Moes Scene switches (I am not 100% certain they will bind the same as Ikea switches).
However I just listen to the MQTT topic in Home Assistant, i.e.:
triggers:
- trigger: mqtt
options:
topic: zigbee2mqtt/FrontDoorSwitch/action
- trigger: mqtt
options:
topic: zigbee2mqtt/BedroomSwitch/action
...
You will need to do some work to parse out the payload of the MQTT message, but depending upon how many switches you have ** / the complexity of your automations, it can simplify your overall setup.
** - I have six 4-Gang scene switches each with 3 actions (6 x 4 x 3 = 72) which are all process by a single automation.