Hello,
I have created a script that has a for each loop in it. I would like to pass a field value to that for each loop but that doesn’t seem to work.
This code works.
fields:
group_covers:
description: group of covers to move
example: cover.raffstores_eg_west
group_position:
description: Position of the cover
example: 60
group_tilt_position:
description: Tilt position (optional)
example: 50
alias: group_cover_position_tilt
sequence:
- repeat:
for_each: "{{ state_attr('cover.raffstores_eg_wintergarten', 'entity_id') }}"
sequence:
- action: script.turn_on
target:
entity_id: script.cover_position_tilt
data:
variables:
entity_id: "{{ repeat.item }}"
position: "{{ group_position }}"
tilt_position: "{{ group_tilt_position }}"
enabled: true
description: ""
icon: mdi:blinds-horizontal
But if I change the for each command so it uses the field value, the whole things stops working.
fields:
group_covers:
description: group of covers to move
example: cover.raffstores_eg_west
group_position:
description: Position of the cover
example: 60
group_tilt_position:
description: Tilt position (optional)
example: 50
alias: group_cover_position_tilt
sequence:
- repeat:
# Next line is change compared to the version above
for_each: "{{ state_attr('{{ group_covers }}', 'entity_id') }}"
sequence:
- action: script.turn_on
target:
entity_id: script.cover_position_tilt
data:
variables:
entity_id: "{{ repeat.item }}"
position: "{{ group_position }}"
tilt_position: "{{ group_tilt_position }}"
enabled: true
description: ""
icon: mdi:blinds-horizontal
Any idea how to get this working?
Thanks and best regards,
Tim