I know the following doesn’t work, but is there a way that I can I can set a variable (answer
) within a template?
Is there a batter way to do this? …I am trying to find out what the highest (of the 6 possible) scheduled temperatures is. Note that not every temp is scheduled.
- name: "Heating max sched temp"
state: >
{% set sched1 = states('input_boolean.heating_1_scheduled') %}
{% set sched2 = states('input_boolean.heating_2_scheduled') %}
{% set sched3 = states('input_boolean.heating_3_scheduled') %}
{% set sched4 = states('input_boolean.heating_4_scheduled') %}
{% set sched5 = states('input_boolean.heating_5_scheduled') %}
{% set sched6 = states('input_boolean.heating_6_scheduled') %}
{% set temp1 = states('input_number.heating_1_temp')|float %}
{% set temp2 = states('input_number.heating_2_temp')|float %}
{% set temp3 = states('input_number.heating_3_temp')|float %}
{% set temp4 = states('input_number.heating_4_temp')|float %}
{% set temp5 = states('input_number.heating_5_temp')|float %}
{% set temp6 = states('input_number.heating_6_temp')|float %}
{% if sched1 == 'on' %} {% then set answer == temp 1 %}
{% if sched2 == 'on' and (temp2 > answer) set answer = temp2 %}
{% if sched3 == 'on' and (temp3 > answer) set answer = temp3 %}
{% if sched4 == 'on' and (temp4 > answer) set answer = temp4 %}
{% if sched5 == 'on' and (temp5 > answer) set answer = temp5 %}
{% if sched6 == 'on' and (temp6 > answer) set answer = temp6 %}
{{ answer }}
edit: I guess I can do this using an automation.