random_color:
  alias: Random Color
  mode: parallel

  fields:
    lights:
      description: List of lights that will be turned on with a random color
      example: "[light.bathroom, light.kitchen]"
      required: true
    force:
      description: Set random color although light is already turned on (optional, default false)
      example: "true"
      default: false

  variables:
    force: "{{ force | default(false) }}"
    colors: [
      [255, 0, 0],
      [255, 128, 0],
      [255, 255, 0],
      [128, 255, 0],
      [0, 255, 0],
      [0, 255, 128],
      [0, 255, 255],
      [0, 128, 255],
      [0, 0, 255],
      [128, 0, 255],
      [255, 0, 255],
      [255, 0, 128]
    ]

  sequence:
    - repeat:
        count: "{{ lights | length }}"
        sequence:
          - variables:
              light: "{{ lights[repeat.index-1] }}"
          - condition: template
            value_template: "{{ force is sameas true or is_state(light, 'off') }}"
          - service: light.turn_on
            target:
              entity_id: "{{ light }}"
            data_template:
              rgb_color: "{{ colors | random }}"

random_color:
  alias: Random Color
  mode: parallel

  fields:
    lights:
      description: List of lights that will be turned on with a random color
      example: "[light.bathroom, light.kitchen]"
      required: true
    force:
      description: Set random color although light is already turned on (optional, default false)
      example: "true"
      default: false

  variables:
    force: "{{ force | default(false) }}"
    color: "{{ [
      [255, 0, 0],
      [255, 128, 0],
      [255, 255, 0],
      [128, 255, 0],
      [0, 255, 0],
      [0, 255, 128],
      [0, 255, 255],
      [0, 128, 255],
      [0, 0, 255],
      [128, 0, 255],
      [255, 0, 255],
      [255, 0, 128]
    ] | random }}"

  sequence:
    - repeat:
        count: "{{ lights | length }}"
        sequence:
          - variables:
              light: "{{ lights[repeat.index-1] }}"
          - condition: template
            value_template: "{{ force is sameas true or is_state(light, 'off') }}"
          - service: light.turn_on
            target:
              entity_id: "{{ light }}"
            data_template:
              rgb_color: "{{ color }}"

Set same random color of all lights when calling script
Set same random color of all lights when calling script
