Help with template condition inside an automation

Hi all,

I have the following automation

id: '1654276813376'
alias: Alarmo - Tapparelle Armed Away
description: ''
trigger:
  - platform: state
    entity_id:
      - alarm_control_panel.alarmo
    to: armed_away
    id: alarmo_is_armed_away
  - platform: state
    entity_id:
      - alarm_control_panel.alarmo
    to: disarmed
    id: alarmo_is_disarmed
condition:
  - condition: template
    value_template: |2-
          condition: template
          value_template: '{{ trigger.from_state.state != "triggered" }}'
action:
  - choose:
      - conditions:
          - condition: trigger
            id: alarmo_is_armed_away
        sequence:
          - service: scene.create
            data:
              scene_id: alarmotapparelle
              snapshot_entities:
                - cover.tapparellacameradaletto_cover_1
                - cover.tapparellacameradiadele_cover_1
                - cover.tapparellasoggiorno_cover_1
                - cover.tapparellastudio_cover_1
                - cover.tapparellacucina_cover_1
          - service: cover.close_cover
            data: {}
            target:
              entity_id:
                - cover.tapparellastudio_cover_1
                - cover.tapparellasoggiorno_cover_1
                - cover.tapparellacucina_cover_1
                - cover.tapparellacameradiadele_cover_1
                - cover.tapparellacameradaletto_cover_1
          - service: script.my_notify
            data:
              title: Alarmo
              message: Tapparelle Abbassate
              no_show: true
      - conditions:
          - condition: trigger
            id: alarmo_is_disarmed
          - condition: time
            before: '22:00:00'
        sequence:
          - service: scene.turn_on
            data: {}
            target:
              entity_id: scene.alarmotapparelle
    default: []
mode: restart

The issue is that the condition is not met when alarm_control_panel.alarmo changes to armed_away

Can someone please support me?

thanks

You’ve “double-templated” — somehow you’ve pasted a template condition within itself. You want:

condition:
  - condition: template
    value_template: "{{ trigger.from_state.state != 'triggered' }}"

Alternatively, use:

    not_from: 'triggered'

in both of your triggers and lose the condition (docs).

`condition:

  • condition: template
    value_template: “{ trigger.from_state.state != ‘triggered’ }}”`

I tested first solution and still does not work.

I think I cannot use the second because then I will not be able to split between different triggers right?

EDIT:

I changed the " with ’ and now works (don’t ask me why)

condition:

  • condition: template
    value_template: “{{ trigger.from_state.state != “triggered” }}”
1 Like

My fault: I missed a bracket in my code above, now fixed. You corrected it when changing quotes over.

1 Like