I have several scripts and automations to manage which garage doors open and close when someone arrives home, depending on whether the garage spots are empty, etc.
For cases where I want to ask the user which door he/she wants to open, I wrote this “ask which door to open” script that gets called from other scripts. I get a “template rendered invalid service” error. I narrowed it down to line 12 the template is somehow producing a blank result instead of the contents of the variable. If I replace the template with a hard-coded notification device, it works fine.
What am I doing wrong here? Thanks in advance!
alias: Which Door Do You Want to Open
fields:
which_device:
default: notify.mobile_app_iphone_de_marcos
sequence:
- alias: Set up variables for the actions
variables:
action_left: "{{ 'LEFT_' ~ context.id }}"
action_middle: "{{ 'MIDDLE_' ~ context.id }}"
action_none: "{{ 'NONE_' ~ context.id }}"
- alias: Ask which door to open
action: "{{ which_device }}"
data:
message: Welcome home. Which garage door would you like to Open?
data:
actions:
- action: "{{ action_left }}"
title: Left
- action: "{{ action_middle }}"
title: Middle
- action: "{{ action_none }}"
title: None
- alias: Wait for a response
wait_for_trigger:
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_left }}"
trigger: event
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_middle }}"
trigger: event
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_none }}"
trigger: event
continue_on_timeout: false
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_left }}"
sequence:
- action: script.smart_garage_door_opener
data:
which_door: cover.left_door
flash_lights: "no"
what_to_do: open
notification_type: none
announcement_type: none
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_middle }}"
sequence:
- action: script.smart_garage_door_opener
data:
which_door: cover.middle_door
flash_lights: "no"
what_to_do: open
notification_type: none
announcement_type: none
default:
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
description: ""
mode: parallel