I have this automation which is supposed to maintain a temperature of 21°C in several rooms when we’re home:
# Maintain temperature when home
- id: "5021549414"
alias: maintain_temp_when_home
trigger:
- platform: numeric_state
entity_id:
- climate.wiser_hallway
- climate.wiser_bathroom
- climate.wiser_bedroom
- climate.wiser_living_room
value_template: "{{ state.attributes.current_temperature }}"
below: 21
- platform: time_pattern
hours: "/1"
mode: parallel
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.season_temp_threshold
state: "on"
- condition: time
after: "08:00:00"
before: "18:00:00"
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.person1_home
state: "on"
- condition: state
entity_id: binary_sensor.person2_home
state: "on"
action:
- service: climate.set_temperature
data_template:
entity_id: >-
{% if trigger.entity_id == 'climate.wiser_hallway'
or trigger.entity_id == 'climate.wiser_bathroom'
or trigger.entity_id == 'climate.wiser_bedroom'
or trigger.entity_id == 'climate.wiser_living_room' %}
{{ trigger.entity_id }}
{% else %}
{% if (state_attr('climate.wiser_hallway', 'current_temperature') < 21 ) %}
climate.wiser_hallway
{% elif (state_attr('climate.wiser_bathroom', 'current_temperature') < 21 ) %}
climate.wiser_bathroom
{% elif (state_attr('climate.wiser_bedroom', 'current_temperature') < 21 ) %}
climate.wiser_bedroom
{% elif (state_attr('climate.wiser_living_room', 'current_temperature') < 21 ) %}
climate.wiser_living_room
{% endif %}
{% endif %}
temperature: 21
hvac_mode: auto
And is sort of works… but not really, the problem is in this section:
{% if (state_attr('climate.wiser_hallway', 'current_temperature') < 21 ) %}
climate.wiser_hallway
{% elif (state_attr('climate.wiser_bathroom', 'current_temperature') < 21 ) %}
climate.wiser_bathroom
{% elif (state_attr('climate.wiser_bedroom', 'current_temperature') < 21 ) %}
climate.wiser_bedroom
{% elif (state_attr('climate.wiser_living_room', 'current_temperature') < 21 ) %}
climate.wiser_living_room
{% endif %}
I wrongly assumed that if more than one these is below 21°C, that the temperature of those entities will be set to 21°C and the hvac mode to auto. However it only ever affects the first entity which meets these criteria.
What I want to happen that the automation should affect any/all of the entities where the current temperature is below 21°C and ignore those where the temperature is above 21°C.
Thanks for any help