@toot4fun wrote:
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.
Posts: 4
Participants: 3