I’m trying to build a script to store the volume level in each echo in the house using the efficiency of a for...loop so I’m not writing out more code each time I add an echo in the future.
The loop is building the number of services entries needed in the script. HA is giving me this error that I can’t seem to get past.
You can’t generate complex data structures from a template like that - you can only generate a value for a key. I believe you could do something like this with a YAML loop: Script Syntax - Home Assistant
Only because you have misunderstood a template’s purpose. It is used to compute an option’s value. You’re trying to use it to generate YAML statements (in other words to generate additional options). That has never been a valid use-case in Home Assistant (and the documentation contains no description or examples of it).
There is no service call to create an input_boolean entity. However, if you have already created all of the required input_booleans, it is possible to loop through them and assign values. Let me know if this is the case and I can help you compose the script.
Thanks for the background and your offer to help. I did misunderstand its capabilities/purpose.
All of my of the entities used in the script are predefined. Essentially I have a list of my echoes using input_select: {{state_attr('input_select.echo_entity_listing', 'options')}}
and I have the same number of input_number entities that have the same name as the echo with “_volume” appended (e.g. input_number.garage_echo_volume):
And I want to loop through them to store the volume before I modify it, so I’m able to set it back to the stored level later in the script.