Variable in condition

Hi.

I’m trying to use variable ‘event’ in condition but it does not seems to work. In the notification it does. What am I missing?

alias: test button
description: ""
trigger:
  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: device_rotated
    subtype: right
    variables:
      event: right_slow
  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: device_rotated
    subtype: left
    variables:
      event: left_slow
  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: button_1
    variables:
      event: click
  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: remote_button_double_press
    subtype: button_1
    variables:
      event: double_click
  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: device_rotated_fast
    subtype: right
    variables:
      event: right_fast
  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: device_rotated_fast
    subtype: left
    variables:
      event: left_fast
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: |-
              {% if event == 'click' %}
              {% endif %}
        sequence:
          - service: media_player.media_play_pause
            target:
              device_id: f01edbedb27392992fc75d2a0d7e2838
            data: {}
            enabled: true
      - conditions:
          - condition: template
            value_template: |-
              {% if event == 'right_slow' %}
              {% endif %}
        sequence:
          - service: media_player.volume_up
            target:
              device_id: f01edbedb27392992fc75d2a0d7e2838
            data: {}
            enabled: true
      - conditions:
          - condition: template
            value_template: |-
              {% if event == 'left_slow' %}
              {% endif %}
        sequence:
          - service: media_player.volume_down
            target:
              device_id:
                - f01edbedb27392992fc75d2a0d7e2838
            data: {}
            enabled: true
  - service: notify.mobile_app_amits_iphone_13_pro
    metadata: {}
    data:
      message: "{{event}}"
    enabled: true
  - service: telegram_bot.send_message
    metadata: {}
    data:
      message: "{{event}}"
    enabled: true
mode: single

Instead of:

          - condition: template
            value_template: |-
              {% if event == 'click' %}
              {% endif %}

use

          - condition: template
            value_template: "{{ event == 'click' }}"

or the shorthand version:

          - "{{ event == 'click' }}"

Your templates are not returning anything: they should return true or false.

You could also use trigger IDs instead of variables, so:

  - device_id: 9a9d26506c94bc11172ddbb22ffff824
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: button_1
    id: click

and then use trigger.id in place of event in the action block.

Great. Thanks for your help.