Pass Variables to is_state

Good morning-

New HA user here and I’ve been banging my head against the wall for a few days trying to build some home alarm automation. Basically, if someone triggers the alarm I want to give them a period of time (30 seconds) to turn off the automation and stop the siren from going off. The summary of my question is: Can I pass variables to is_state() in a script? Here’s my code:

automations.yaml

- id: automation.alarm_entry_doors_always
  alias: Alarm - Entry Doors - Always
  description: 'Triggers when alarm is armed and an entry door is opened any time.'
  trigger:
  - entity_id: group.all_doors
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - service: script.turn_on
    entity_id: script.1576457883509
    data:
      variables:
        title: 'Home Alarm'
        automation_name: 'automation.alarm_entry_doors_always'
        automation_friendly_name: 'Alarm - Entry Doors - Always'

scripts.yaml

'1576457883509':
  alias: Alarm - Triggered
  sequence:
  - service: notify.notify
    data_template:
      title: "{{ title }}"
      message: "{{ automation_friendly_name }} triggered. Current state of {{ automation_name }} is: {{ is_state('{{ automation_name }}','on') }}. Delaying 30 seconds."
  - delay: 00:00:30
  - service: notify.notify
    data_template:
      title: "{{ title }}"
      message: "{{ automation_friendly_name }} triggered. Current state of {{ automation_name }} is: {{ is_state('{{ automation_name }}','on') }}."
  - condition: template
    value_template: "{{ is_state('{{ automation_name }}','on') }}"
#  - service: light.turn_on
#    data:
#      entity_id: group.all_lights
  - service: notify.notify
    data_template:
      title: "{{ title }}"
      message: "{{ automation_friendly_name }} activated."

Any other suggestions for this n00b would also be appreciated.

value_template: "{{ is_state( automation_name , 'on') }}"

Yes, you can. E.g.:

    value_template: "{{ is_state(automation_name,'on') }}"

But also an FYI. An automation’s on/off state indicates whether it is, well, on or off, meaning whether or not it is monitoring and responding to triggers. It does not indicate whether or not it has “fired”, aka “triggered.”

Wow, that was so simple and I can’t believe I couldn’t figure that out on my own. Thank you!!

@pnbruckner, thanks for the feedback. The intent here is to check the state of the automation that triggered the alarm to see if it’s still enabled. My thought was this: The alarm is on and someone walks in the door. The automation triggers the alarm script which lets them know via some method (flashing lights, phone notification, etc) that they’ve triggered the alarm. They have a period of time (30 seconds) to disable the automation so that the alarm won’t actually go off. After the 30 second delay, the script checks the state of the automation to see if it’s off. If it is, nothing more happens. If it’s not, then I have an intruder so turn on the lights, siren, release the hounds, etc.