Add foreach loop in script

Tags: #<Tag:0x00007f7390468420>

I think it would be useful to add foreach as a new type of loop to repeat, as it is not always easy/possible/nice to do it using repeat.index.

Additional related ideas:

  • Saving current value in repeat.value
  • Iterating over arrays created using jinja template
    (e.g. {{ state_attr('group.all_devices', 'entity_id') }})

Calling @pnbruckner (creator of repeat action)

1 Like

why not make life easier? Use Node Red. You can write functions in JavaScript.

I don’t need NR, I can do everything in HA. If I want to write code I use built-in python script.

1 Like

Could you give an example of how it could be used? Maybe provide some pseudo-code.