Color Loop a Group of Lights

Greetings,

I’ve recently found a few posts about color looping a light. I’ve implemented the automation and script and for a single light, or a group of lights (all one color), that works fine.

What I’m trying to work out is if it’s possible to do a color chase loop across multiple lights in a group? Pick your colors, loop through all the lights so every light has a different color, every few seconds to get the colors to ‘chase’?

I know I can plunk in three automations, one for each light, then turn them all on… but that just seems clunky. I was more looking for something that I could set up an automation with a light group and have the script do the heavy lifting. I’m not quite sure how to go about this. Somehow parse out all the lights in a group and assign them a color, from a list, either randomly, or in order…

Currently here is my YAML for a single light/group:

Automation:

alias: Christmas led
description: Rotating color every second
trigger:
  - hours: '*'
    minutes: '*'
    platform: time_pattern
    seconds: /5
condition: []
action:
  - service: script.1656045071795
    data:
      entity: light.ceiling1
mode: single

Script:

alias: christmas light
sequence:
  - service: light.turn_on
    data:
      rgb_color: |
        {% if now().second % 2 == 0 %}
          [255, 0, 0]
        {% else %}
          [0, 255, 0]
        {% endif %}
      transition: 1
    target:
      entity_id: '{{ entity }}'
mode: single
fields:
  entity:
    description: The entity that will be rainbowed
    example: light.bathroom
icon: mdi:pine-tree

Thanks everyone.

And answered!

You just add all the lights you want. About the only thing that would be good is to set up a helper that could be set to change the timing via a slider, or something.