Hi there;
I can’t remember when I wrote this template but i’m 99% sure I yoinked it from this community, but now I need to modify it.
Currently the below automation works mostly but I need a way to identify if a switch is on or off and excluding the “on” switches from the list. i.e. I need to identify the switch on top of the list that is “off”.
Currently it identifies all switches in order of greatest temperature difference, regardless of switch status.
Does anyone with template knowledge know how to add a line to the second “then” template to only identify & list the switches that are off?
Thanks
- id / alias; "progressive heat zone control"
triggers:
- entity_id:
- sensor.inside_temp_average
conditions:
- condition: state
entity_id: climate.daikin
state: heat
actions:
- if:
- condition: template
value_template: '{% set nameslist = expand("sensor.heating_difference_master","sensor.heating_difference_room2","sensor.heating_difference_room3","sensor.heating_difference_bathroom","sensor.heating_difference_office","sensor.heating_difference_kitchen")%}
{% set nameslist = nameslist | sort(attribute=''state'',reverse = true ) | map ( attribute=''entity_id'' ) | list %}
{% set nameslist = nameslist | first | string %}
{% set entity_is = (state_attr(nameslist, ''control_switch'')) %}
{% if states(entity_is) == ''off'' %}
true
{% else %}
false
{% endif %}'
then:
- data_template:
entity_id: '{% set nameslist = expand("sensor.heating_difference_master","sensor.heating_difference_room2","sensor.heating_difference_room3","sensor.heating_difference_bathroom","sensor.heating_difference_office","sensor.heating_difference_kitchen")%}
{% set nameslist = nameslist | sort(attribute=''state'',reverse = true ) | map ( attribute=''entity_id'' ) | list %} {% set nameslist = nameslist | first | string %} {{ (state_attr(nameslist, ''control_switch'')) }}'
action: switch.turn_on
mode: single