Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 107907

Use of variables in template statements

$
0
0

I am experimenting with the newly introduced variables and am having problems understanding where they can be used. E.g., in a script sequence:

- variables:
  home: '{{ (states("group.familie") == "home") }}'
  time: '{{ now().strftime("%H:%M:%S") }}'
  daytime: '{{ (time > states("input_datetime.off")) and (time < states("input_datetime.on")) }}'
  armed: '{{ states("alarm_control_panel.home") == "armed_away" }}'

expressions works perfectly fine (e.g. time is used and resolved in daytime). However it seems that using them in statements:

  service: >-      
    {% if (home and daytime and armed) %}
      alarm_control_panel.alarm_disarm
    {% elif (((not home) or (not daytime)) and (not armed)) %}
      alarm_control_panel.alarm_arm_away
    {% else %}
      script.noop
    {% endif %}

doesn’t seem to resolve them properly or at all. In this case the ‘if’ branch is always true.

I’m dumping the content of the variables into the log file within the actions and the variables all have the expected values.

Do I miss anything or I am I completely misunderstanding how to use variables?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 107907

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>