How to trigger on any action of an Zigbee2MQTT device?

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?

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.

What you want is possible if you use a State Trigger to monitor the device’s Event entity.

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.

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.