Automation to set same random colour on two Hue lights

Hi,

I hope this is the right category…

For a while I’ve used the following to change my Hue lights colour randomly at 5 minute intervals.

- id: '1573472848968'
  alias: Hall Lightstrip Random
  description: ''
  trigger:
  - hours: '*'
    minutes: /05
    platform: time_pattern
    seconds: '00'
  condition:
  - after: sunset
    condition: sun
  - before: '21:59:59'
    condition: time
  action:
  - data:
      effect: random
      entity_id: light.hue_lightstrip_plus_1
    service: light.turn_on

Now I have a second Hue lightstrip that I want to operate the same way as the first, same colour, changing at the same time. I added the following to the action…

  - data:
      effect: random
      entity_id: light.hue_lightstrip_plus_2
    service: light.turn_on

and it turned on and changed at the same time but to a different random colour unsurprisingly.

Can anyone suggest how I can get them both to change to the same random colour please?

Many thanks,

Matt

off top of head

some like this

- id: '1573472848968'
  alias: Hall Lightstrip Random
  description: ''
  trigger:
  - hours: '*'
    minutes: /05
    platform: time_pattern
    seconds: '00'
  condition:
  - after: sunset
    condition: sun
  - before: '21:59:59'
    condition: time
  action:
  - data:
      effect: random
      entity_id: 
         - light.hue_lightstrip_plus_1 
         - light.hue_lightstrip_plus_2
    service: light.turn_on

Thank you. Having tried that they are still both changing to different random colours, so I conclude that the random effect command is sent to the light device and it’s the light device that then selects the random value. I think I may have to calculate a random colour upstream and then send it to both lights.

done it!

- id: '1573472848999'
  alias: Hall Lightstrip Both Random
  trigger:
  - hours: '*'
    minutes: /01
    platform: time_pattern
    seconds: '00'
  condition:
  - after: sunset
    condition: sun
  - before: '21:59:59'
    condition: time
  action:
    service: light.turn_on
    data_template:
      entity_id:
         - light.hue_lightstrip_plus_1 
         - light.hue_lightstrip_plus_2
      rgb_color: ['{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}']
2 Likes

Now all I need to do is work out how to set the brightness of ONE of the two lights to 50%!

just add other data action to it

Will that work on only 1 of the 2 lights? What I’ve done as a temporary measure is added a second action to reduce the brightness of the 2nd light. The delay is almost imperceivable.

try this
you have to add a -
to the first one so python know its a list( more than one thing to do

Im guessing on the spaces

  action:
    - service: light.turn_on
       data_template:
       entity_id:
          - light.hue_lightstrip_plus_1 
          - light.hue_lightstrip_plus_2
       rgb_color: ['{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}', '{{ (range(0, 255)|random) }}']
    - service: light.turn_on
       data_template:
       entity_id:
          - light.hue_lightstrip_plus_{{ (range(1, 2)|random) }}
       brightness_pct: 50
2 Likes

Awesome, thank you