Blueprint: Calling Scripts in a loop

Hello Home Assistant Experts,

I am trying to create a blueprint that takes a set of scripts as an input. When it is triggered and the conditions are met, all scripts shall be executed. I started out with a blueprint that would take a single script as input and call that - this original version of the blueprint worked. I am now facing problems with extending this to inputting and calling multiple scripts. See below for my current (non-working) version of the blueprint and even further below for some context on what I’m actually trying to achieve.

With this version of the blueprint, when trying to create an automation from this blueprint, I get the error message “Message malformed: template value does not contain a dynamic template for dictionary value @ data['action'][0]['repeat']['for_each']”. I tried googling for the error message and also for more general information on how to do for_each: on a set of inputs - the results have brought me to what you see before you. I believe that the problem is pretty much the entirety of the action: section, and that I’m not converting the list of inputs to a dict in the right way - although I have not found any hints as to what the correct way would be.

Can you please let me know how I can configure a number of scripts as inputs and have them all called in a loop from this blueprint?

  name: Conditional Shutter Control
  description: Based on a time helper and an on/off switch, actuate shutters.
  domain: automation
      name: Time to fire the automation
            domain: input_datetime
      name: Whether the automation should currently be active
            domain: input_boolean
      name: The scripts to execute
            domain: script
          multiple: true

  local_the_scripts: !input the_scripts

  - platform: time
    at: !input time_helper

  - condition: state
    entity_id: !input enable_helper
    state: "on"

    for_each: local_the_scripts
      - service: script
        #data: {}
          entity_id: repeat.item

mode: single

Additional Context: I have shutters on all windows of my house and want to move them to a “sun protection” position - basically as open as possible without letting direct sunlight into the room. I have figured out the correct opening percentage for every shutter. I then created scripts for each room that have the specific shutter positions for that room. With these scripts, I can manually trigger the shutters to move.

I now want to create automations for every side of the house (south, southwest, west,…) to begin sun protection for all rooms on that side at a certain time, or to open the shutters back up on that side on a certain other time.

I have the overall setup working with lots of cloned automations. However, I want the timings to be adjustable through the Lovelace UI to make adjustments more convenient for me and for other members of the household. Also, I want to be able to easily disable sun protection on cloudy days - which currently means going into automation settings and disabling the existing automation outright. Here, another button in the UI would be really convenient.

I’m not fixed on using scripts - A solution that lists the respective shutters and their individual positions would also be acceptable, provided that I can still trigger the sun protection setting manually, independent of the configured time_helper.

Any help is appreciated!


You can’t generate the main yaml like that.

I suggest pulling that list apart in variables and try to load them one by one in each their own action statements. Empty action statements just won’t do anything so you can have like 10 action statements all with script1, script2… script10 in a stack and only the first 4 are populated.

Thinking that may be loop-able, but I would build it as a stack first to get it working then try to be clever with a loop.

Hello Sir_Goodenough,

sadly, your suggestion does not work. If I leave the inputs empty, Home Assistant reports an error on missing inputs. I guess I cloud create a “do nothing” script to fill those values, but that might be too much stacking of absurdities over sticking with non-blueprinted copy-pasted scripts.


These all work fine…
HA_Blueprints/Automations/Zigbee2MQTT-Xiaomi_Cube_Controller_MQTT_Triggered.yaml at d1c15d75a7b5fa3042d60f7eee2d7633ea8a27a3 · SirGoodenough/HA_Blueprints · GitHub.
Perhaps the [] that’s in the default is required?
All I know is when this is run, there are no errors and if there isn’t an action but the branching selects it, it just falls thru doing nothing.