Disco Lights

Hi I am trying to create an automation that flashes my front room lights flash like disco lights

The code below works but when i turn off “Disco” the light stays in the colour it was on at the time so if the light was red when i turn the light on normally it is red . Is there anyway when i turn the light on normally it reverts to white.

  • id: disco
    alias: ‘Disco’
    initial_state: ‘on’
    - condition: state
    entity_id: switch.living_room
    state: ‘on’
  • platform: time
    seconds: ‘/1’
    service: light.turn_on
    entity_id: light.0720036984f3eb96cbc2
    rgb_color: [’{{ (range(0, 255)|random) }}’,’{{ (range(0, 255)|random) }}’,’{{ (range(0, 255)|random) }}’]

You could set up another automation that triggers when the switch you use to start the flashing lights gets turned off it sets the light to white and then off. Then when you turn the light on normally it will already be white.