Why is "template" running fine with simple "condition" but not with "actions choose condition"?

I struggle with actions choose and template. The same template is working fine with a simple condition but doesn’t when I use in the actions with a choose. The template I use is {{ trigger.event.data.args.value == 2 }}.

What do I miss ?

alias: Test with choose
description: ''
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: 9869142560b5a7389e137f780fdff2dc
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.args.value == 2 }}'
        sequence:
          - service: persistent_notification.create
            data:
              message: Hello
    default: []
mode: single

Example of automation with a simple condition working fine with the same template https://paste.ubuntu.com/p/JMJWY8NsMv/

As advised I also tried to edit the YAML directly with

action:
  - choose:
      - conditions:
          - '{{ trigger.event.data.args.value == 2 }}'

Instead of

action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.args.value == 2 }}'

This still doesn’t work.

Remark: The - '{{ trigger.event.data.args.value == 2 }}' works well with simple condition but not with actions choose …)

1 Like