Hi,
I’m new to HA and getting on well, building all sorts of things and mostly working it all out using these forums. I’m though stuck on getting an action to loop through a variable set as part of a trigger.
The automation is designed to turn heating off in specific zones when a swtich is turned off in HA for 5 seconds. This works fine when I have one climate entity in a zone, but breaks when I try adding a for loop.
This is the working code which handles just one climate entity:
alias: Turn Heating Off
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.heating_lounge_schedule_switch
to: "off"
for:
hours: 0
minutes: 0
seconds: 5
variables:
climate_ids:
climate_id_1:
name: lounge
- platform: state
entity_id:
- input_boolean.heating_study_schedule_switch
to: "off"
for:
hours: 0
minutes: 0
seconds: 5
variables:
climate_ids:
climate_id_1:
name: study
- platform: state
entity_id:
- input_boolean.heating_bathrooms_schedule_switch
to: "off"
for:
hours: 0
minutes: 0
seconds: 5
variables:
climate_ids:
climate_id_1:
name: main_bathroom
climate_id_2:
name: second_bathroom
condition: []
action:
- if:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
then:
- action: climate.set_temperature
metadata: {}
data:
temperature: 10
target:
entity_id:
- climate.{{ climate_ids['climate_id_1'].name }}
mode: single
I was then trying to update the target entity_id to:
entity_id: >
{% for climate_id in climate_ids %}
- climate.{{ climate_ids['climate_id'].name }}
(% endfor %}
However, this generates an error:
Message malformed: not a valid value for dictionary value @ data[‘action’][0][‘then’][0][‘target’][‘entity_id’]
Any ideas?