[0.115.0b0] New condition syntax in scripts/actions

I don’t know whether it’s better to post here or to submit an issue to github, but I’m puzzling over how to use the new condition template syntax in scripts and actions. The docs say this:

The template condition has a shorthand notation that can be used to make your scripts and automations shorter.

It works fine in the condition: block of an automation, and I can use it in the choose: block in a script/action, but I was hoping that it would also be usable in ‘inline’ conditions in scripts/actions such as this:

  action:
    - data_template:
        entity_id: >-
          {{ 'group.lr' if trigger.event.data.control == 'DON' else 'group.lr_night' }}
      service_template: >-
        homeassistant.turn_{{ 'on' if trigger.event.data.control == 'DON' else 'off' }}
    - condition: template
      value_template: "{{ trigger.event.data.control == 'DOF' }}"
    - entity_id: script.nightlight
      service: script.turn_on

It’s effectively the same syntax that one would use in the other two cases, but I can’t work out what syntax, if any, should be used here. I was hoping for something like this, as can be used elsewhere:

  - "{{ trigger.event.data.control == 'DOF' }}"

but not that nor any variant passes the config check. Is choose: the only place in a script or action where the new syntax can be used?

Looking at the examples in the PR:

I don’t see that use-case described so maybe it was omitted. You should probably check with the PR’s author.

Sure, hoping they’ll chime in here. If it’s intended to shorten/simplify scripts, adding a choose: or a dummy ‘condition: or’ or ‘condition: and’ with a single condition doesn’t really help :slight_smile:

Frenck found a solution for the shorthand in an action/script, but he and Paulus didn’t like it and decided to pull support for the shorthand notation outside of repeat/while/until, condition blocks in automations, and (probably?) and/or blocks. He’s going to make it clear in the docs what’s supported.

I can understand why they feel that way; it looks lost and lonely when used like this:

  action:
    - service_template: "homeassistant.turn_{{ 'on' if trigger.event.data.control == 'DON' else 'off' }}"
      data_template:
        entity_id: "{{'group.lr' if trigger.event.data.control == 'DON' else 'group.lr_night' }}"
    - "{{ trigger.event.data.control == 'DOF' }}"
    - service: script.turn_on
      entity_id: script.nightlight
      

I agree, it’s kinda weird without a tag or indication of what it’s doing there. Maybe something like

- condition: “{{ blah blah }}”

would be better. The old way wasn’t too onerous, so not a big deal.