- condition: state #check whether garage door is closed
entity_id: binary_sensor.omnilink_garage_dr_{{ garage_door_num }}
state:
- "off"
The only conditions that allow templating are Template conditions… also, it’s best to avoid inline comments.
- alias: check whether garage door is closed
condition: template
value_template: |
{{ is_state('binary_sensor.omnilink_garage_dr_'~ garage_door_num, 'off') }}
I don’t know if the following was just for this post, but it would break your template:
garage_door_num: > #according to documentation variables defined here have script-wide scope?
description: "Open correct garage door for approaching vehicle"
mode: single
triggers:
- trigger: zone
entity_id: device_tracker.sm_s938b
zone: zone.home
event: enter
variables:
garage_door_num: >
{# according to documentation variables defined here have script-wide scope? #}
{# #1 is Jeep, #2 is VW, #3 is Audi, zero means no car connected #}
{% set connected = state_attr('sensor.sm_s938b_bluetooth_connection','connected_paired_devices')%}
{% if 'F8:6D:CC:A7:ED:2D (Uconnect-2c5266)' in connected %}
"1"
{% elif '9C:8D:7C:32:6F:52 (VW BT 1706)' in connected %}
"2"
{% elif '00:0E:9F:73:06:72 (Audi UHV 1671)' in connected %}
"3"
{% else %}
"0"
{% endif %}
conditions:
- alias: check whether garage door is closed
condition: template
value_template: |
{{ is_state('binary_sensor.omnilink_garage_dr_'~ garage_door_num, 'off') }}
- alias: In which case no vehicle is connected
condition: template
value_template: "{{ garage_door_num != '0' }}"
actions:
- action: light.turn_on
metadata: {}
target:
entity_id: light.omnilink_garagedr_{{ garage_door_num }}
data: {}