Repeat.item not being interpreted in repeat count

Trying to iterate over a set of zwave_js values to set them all, using a counted repeat, however the repeat.index variable doesn’t appear to get getting interpreted…

Keeps throwing this error:
Error: Node(node_id=83) - NotFoundError: Value 83-112-0-{{ repeat.index }} not found on node Node(node_id=83)

sequence:
  - repeat:
      count: 5
      sequence:
        - device_id: dc9bfca356b835b442332a6f27ee20c4
          domain: zwave_js
          type: set_value
          command_class: 112
          endpoint: "0"
          value: "3"
          property: "{{ repeat.index }}"
description: ""
icon: mdi:led-outline

Looks like zwave_js.set_value doesn’t accept a template as a device action.

What is that device, and what are you trying to achieve?

ZEN32 800LR

Using it to control the scene for some WLED controlled cafe lights. This is just a prototype, at the moment, but the ultimate goal is to only have the little LED on the scene controller lit up, that corresponds to the selected scene.

The meta code would look like:

When scene button 1 is pushed:
   Call script with variable for active_scene = 1
   Loop over the 5 LEDS
      If repeat.index == active_scene then turn LED on
      else turn LED off

Can you try it as a normal service call?

sequence:
  - repeat:
      count: 5
      sequence:
        - service: zwave_js.set_value
          target:
            device_id: dc9bfca356b835b442332a6f27ee20c4
          data:
            command_class: "112"
            endpoint: "0"
            value: "3"
            property: "{{ repeat.index }}"
description: ""
icon: mdi:led-outline

That did it! Thank you, you beautiful human!

Now to learn how to pass variables into scripts :smiley:

2 Likes

Final script

alias: Kitchen - Scene Controller LEDs
sequence:
  - repeat:
      count: 5
      sequence:
        - service: zwave_js.set_value
          target:
            device_id: dc9bfca356b835b442332a6f27ee20c4
          data:
            value: "{{ '3' if repeat.index == active_scene else '2' }}"
            command_class: "112"
            endpoint: "0"
            property: "{{ repeat.index }}"
description: ""
icon: mdi:led-outline

Called from an automation

choose:
  - conditions:
      - condition: and
        conditions:
          - condition: device
            type: is_on
            device_id: 84cbf8b337a69012d2df931f5ae078b3
            entity_id: 1a1340660ec958e1e2c4094ed1838aed
            domain: light
          - condition: state
            entity_id: select.24v_backyard_dig_quad_v3_preset
            state: Sherbet Fairy
    sequence:
      - parallel:
          - type: turn_off
            device_id: 84cbf8b337a69012d2df931f5ae078b3
            entity_id: 1a1340660ec958e1e2c4094ed1838aed
            domain: light
          - service: script.kitchen_scene_controller_leds
            data:
              active_scene: 17
default:
  - parallel:
      - device_id: 84cbf8b337a69012d2df931f5ae078b3
        domain: select
        entity_id: 83f6713f5890782ac95f6c86a9813b3e
        type: select_option
        option: Sherbet Fairy
        enabled: true
      - service: script.kitchen_scene_controller_leds
        data:
          active_scene: 2

which is an action in this blueprint: ZEN32 Scene Controller - Z-Wave JS