Automation - Loop through nodes and set zwave parameter

I’m trying to loop through z-wave nodes, and set a parameter (below). It seems to work, but it skips the first node and also gives the errors (below):

alias: Inovelli - 13 - LED Color Set
description: ''
trigger:
  - platform: sun
    event: sunrise
    offset: '+00:00:00'
condition: []
action:
  - repeat:
      count: '{{ nodes | count }}'
      sequence:
        - service: zwave.set_config_parameter
          data:
            node_id: '{{ nodes[repeat.index] }}'
            parameter: 13
            value: 0
mode: single
max: 30
variables:
  nodes:
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 10
    - 11
    - 12
    - 13
    - 14
    - 15
    - 16
    - 17
    - 18
    - 19
    - 20
    - 21

Errors:

Error while executing automation automation.inovelli_13_led_color_set: expected int for dictionary value @ data['node_id']
Inovelli - 13 - LED Color Set: Error executing script. Error rendering template for repeat at pos 1: UndefinedError: list object has no element 20

v

My bad! repeat.index starts from 1, not zero. Also, if the nodes are just 3 through 21 you can create the list with a template. Lastly, no need to specify max when using single mode. Try:

alias: Inovelli - 13 - LED Color Set
description: ''
trigger:
  - platform: sun
    event: sunrise
    offset: '+00:00:00'
condition: []
action:
  - repeat:
      count: '{{ nodes | count }}'
      sequence:
        - service: zwave.set_config_parameter
          data:
            node_id: '{{ nodes[repeat.index - 1] }}'
            parameter: 13
            value: 0
mode: single
variables:
  nodes: "{{ range(3, 22)|list }}"

Awesome! Works great. Thanks again.