Change Light Bulb Colors

Hello folks! First time posting so be gentle!

My daughter’s birthday party is coming up and I bought a bunch of TP-Link multi-color bulbs. I wanted to create an automation/script/something that would “scroll” through different colors across all of the bulbs. What I did so far was to create different scenes for each color (this works). Then I tried to create both an automation and a script to try to “loop” the scenes so they will run until I turn the off. For some reason the automation nor the script will continue to run. It is almost like the script is still running so it fails to run again. I tried to change Script Mode to “queued” but it still will not run again. I am stumped. Any thoughts on how I can accomplish this? Even if it means scrapping my original idea. Thanks!

Hi @joshuathejac, welcome to the Home Assistant community!

Don’t you wanna share your automation or script, so we could help more?

By the way, have you looked for similar automation in the forum? I bet someone else have already tried a similar thing.

I looked, but the issue with the forum is that the amount of data is vast and my terminology might not be great :slight_smile: I will continue to look and close my own if I find something else! See below with my Script and Automation:

alias: Party Mode
sequence:
  - service: scene.turn_on
    target:
      entity_id: scene.party_blue
    metadata: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.party_green
    metadata: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.party_purple
    metadata: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.party_red
    metadata: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.party_turquoise
    metadata: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.party_orange
    metadata: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.party_blue
    metadata: {}
mode: queued
icon: mdi:party-popper
max: 240

and I am using this automation to call the script:

alias: Party Mode
description: Just what it sounds like
trigger:
  - device_id: c36e366738474e5be0246fa6c149331b
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
condition: []
action:
  - service: script.party_mode
    data: {}
  - repeat:
      until:
        - condition: device
          type: is_on
          device_id: 782fa6bea85c6e0131c93c1038181068
          entity_id: switch.kitchen_island_pendants
          domain: switch
      sequence: []
mode: single

Effectively I would like the script to run until I turn on the kitchen lights :smiley:

Thanks again!

Try this:

alias: Party Mode
description: Just what it sounds like
trigger:
  - device_id: c36e366738474e5be0246fa6c149331b
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
condition: []
action:
  - repeat:
      until:
        - condition: device
          type: is_on
          device_id: 782fa6bea85c6e0131c93c1038181068
          entity_id: switch.kitchen_island_pendants
          domain: switch
      sequence:
        - service: script.party_mode
          data: {}
mode: single

I’ve moved the script call to inside the loop. As it was before, it was calling the script and then starting the loop with no actions inside the loop.

Wow, I guess I need to start doing things in the yaml rather than just relying on the UI. I’ll give it a shot! Thanks!

Well, I like more playing with yaml when I want an overview from the code, but the UI is also quite powerful, specially after 2022.9.0.

If you compare to the original code you shared, it’s also visible in the UI that the action was in a separated box from the repeat…

But again, I personally like more to use yaml for this kind of overview.

1 Like

Hey thanks for showing it in the UI. I get what I did now - I’m sort of thinking backwards - I called the service and then told something to loop, but really nothing. I needed to create the loop and then embed the service call inside it. I’m thinking English instead of math :slight_smile:

1 Like

But in the end, have that solved the issue you had? Could you get the lights changing colors properly?

Your repeat is running until the device is “On”… Shouldn’t be until it is “Off”?

No, I want to turn on the kitchen lights which should turn off the “Party” lights.

Yes, solved! Thanks for the training!

1 Like

I am still not sure to understand. Are you able to set/change the color of the Kasa bulb ?