Correct syntax for "repeat for each ..." using Blueprint multiple input?

I want to write a section of code in YAML (not jinja, because I need to call services) that repeats for each of the items in a blueprint input

The input is

  input:
    thermostat_controls:
      name: DEVICE ENTITY - Thermostat control (mandatory)
      description: One or more thermostat entities that are to be controlled by this automation
      selector:
        entity:
          filter:
            domain: climate
          multiple: true

I referred to the Home Assistant Script Syntax documentation, and am following the examples given.

The current code (fragment) is

variables:
  local_thermostat_controls: !input thermostat_controls

action:
  - repeat:
      for each: "{{ local_thermostat_controls }}" 
      sequence: 
        - if:
          - condition: template
            value_template: "{{ not state_attr(repeat.item, 'temperature') == states(local_required_temperature) }}"
          then:
            # Send the command
            - service: climate.set_temperature
              data:
                temperature: local_required_temperature
              target:
                entity_id: repeat.item

I ge the error message
Message malformed: extra keys not allowed @ data['action'][0]['repeat']['for each']

What are the ‘extra keys’??

I have also tried

  - repeat:
      for each: "{{ local_thermostat_controls | list }}" 

and

  - repeat:
      for each:  !input thermostat_controls

… but all versions produce the same result.

Extra keys are configuration variables that do not belong where they are. This can be invalid variable like in this case… the correct key is for_each not for each. It can also mean there are variables that are not indented properly.

1 Like

Ah of course. I looked at it for hours and never spotted the missing underscore!
I’m surprised the editor (Studio Code Server) didn’t spot this.