Using modulo mathematical operator within a script loop for the repeat.index

Hello,
I would like to use the repeat.index variable of a “repeat sequence” of my script and apply a modulo operation to it.
My goal is to light up groups of adressable leds in sequence. I have 23 groups that have to light up in sequence from group 1 to group 23 in a loop until the exit condition is achieved → a button press here
(nb: a group of led contains more than one led)

  - repeat:
      sequence:
        - service: light.turn_off
          entity_id: light.full_adrresable_ledstrip
        - service: light.turn_on
          data_template:
            entity_id: "light.group_{{ repeat.index }}"
        - delay:
            milliseconds: 500
      until:
        - condition: state
          entity_id: binary_sensor.button
          state: 'on'

Right now this script will light them in sequence until repeat.index = 23.
I want to go beyond, hence use a modulo 23 operator.
If anyone knows how to solve the issue !! and write it up correctly :slight_smile:
Thanks

Ok I just found out the answer by myself by just testing.
Putting the solution in case it interests anyone:
entity_id: "light.group_{{ (repeat.index) % 23 }}"

1 Like