Color Loop effect for any light with color wheel selector

I highly suggest y’all give this much improved, polished and efficient blueprint from this post: Color Loop effect for any light with color wheel selector - #28 by mdolnik a go! I myself migrated to his version you can see my settings that replicate my bp much more efficiently in the thread


Supports any light entity that exposes the color wheel selector:

credits:
Adapted from loic-moriame’s gist comment. I just put it into a blueprint form.


github gist here & import button: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Color Loop
  description: ''
  domain: automation
  input:
    cl_light:
      name: Color Loop Light
      description: 'Choose Light entity to Color Loop'
      selector:
        target:
          entity:
            domain: light

variables:
  colors: |-
    {{ [[0.217,0.077], [0.157,0.05], [0.136,0.04], [0.137,0.065],
        [0.141,0.137], [0.146,0.238], [0.151,0.343], [0.157,0.457],
        [0.164,0.591], [0.17,0.703], [0.172,0.747], [0.199,0.724],
        [0.269,0.665], [0.36,0.588], [0.444,0.517], [0.527,0.447],
        [0.612,0.374], [0.677,0.319], [0.701,0.299], [0.667,0.284],
        [0.581,0.245], [0.477,0.196], [0.385,0.155], [0.301,0.116], 
        [0.217,0.077]] }}

trigger:
  - platform: time_pattern
    hours: '*'
    minutes: '*'
    seconds: '/1'

action:
  - service: light.turn_on
    data_template:
      xy_color: '{{ colors[(now().second/2.5)|round(0)] }}'
      transition: 1
    target: !input cl_light

mode: single
8 Likes

This works great! Thank you! Have 6 overhead RGB LEDs in my game-room. They all change together nicely, but I think I may create 2-3 different automations using this blueprint to further randomize them. Thanks again!

1 Like

Hi,
I’m trying to find a way to cycle through colors in a group of lights by holding down a remote button, then retaining the last color in that cycle at the moment the button is released. Would this blueprint help me with that goal?
I’m new to Home Assistant, so my apologies if this is a stupid question.
Thanks!

1 Like

Create an automation from this blueprint and run it. Then create another automation using your remote button as trigger to toggle this automation. Something like

alias: Loopstopper 2000
description: ''
mode: single
trigger:
  - platform: state
    entity_id: sensor.remote_button
condition: []
action:
  - service: automation.toggle
    data: {}
    target:
      entity_id: automation.colorloop_lightstrip

edit: maybe picture better

So if the color loops, button press will stop at color you want, then pressing the button again the loop re-starts form 1st color again.

Nice! Thanks!
I’ll try it out. I was experimenting with the service automation.turn_on and automation.turn_off with my Aeotec Wallmote since it has hold and release events, but somehow corrupted my scenes.yaml.
I think it has something to do with my LIFX integrations.

Sorry – one more question –
I’ve been playing around with the color_loop.yaml to try to speed up the cycle and I’m having no luck. What would I change to accomplish this?
I tried changing anything that looked like an indicator of time:

- platform: time_pattern
  hours: '*'
  minutes: '*'
  seconds: /0.5
action:
- service: light.turn_on
  data_template:
    xy_color: '{{ colors[(now().second/0.5)|round(0)] }}'
    transition: 0.5

but I really don’t know what I’m doing.

I tried the same and no can do. I believe the issue lies in the fact the minimum possible time for the transition is 1 sec. Anything else I tried made it completely wonky and not smooth at all including messing with the formula above that line.

That said my scripting “knowledge” is mostly copy-pasting stuff from internet and modifying it until it’s near to what I wanted (like this blueprint), so maybe I’m wrong and it is possible to speed it up somehow, I just don’t know how.

That would explain why I’m getting such strange behavior! Oh well. I guess speed is not crucial in this case since I imagine the remote will have some delay issues as well, making precision difficult.
Thanks again for the blueprint and your help.

1 Like

Not familiar with your particular model of remote but I use hue dimmer via zigbee2mqtt and the response is pretty much instant so that shouldn’t be an issue unless you miss the color and have to restart the loop :grinning:

Me again. :smile:
I’ve discovered by looking at my logs, this “Wallmote” fires repeated “key held” events multiple times per second until I let it go. It occurred to me that perhaps your script could be modified so that it’s not time based, but rather changes color for every one of those events with no transition period.
This is what I’m seeing in my Zwave log:

2022-02-13T22:54:17.278Z DRIVER « [Node 015] [REQ] [BridgeApplicationCommand]
                                  │ RSSI: -78 dBm
                                  └─[CentralSceneCCNotification]
                                      sequence number: 159
                                      key attribute:   KeyHeldDown
                                      scene number:    3
2022-02-13T22:54:17.285Z CNTRLR « [Node 015] received CentralScene notification {
                                      "nodeId": 15,
                                      "ccId": "Central Scene",
                                      "ccCommand": "0x03",
                                      "payload": "0x9f0203"

Does this sound feasible? I think it could be worth a try.

You can ofc experiment and if you succeed, do share. But I do really think it comes to the limitation of the lights, regardless of how fast you’re triggering it, if you want the transition smooth, it’ll always take 1 seconds between 2 color changes as that’s as fast as the light can transition (at least I couldn’t get my hue lightstrip any faster).

My LIFX lights are capable of changing colors pretty quickly, but I’m not sure if there’s a limitation of Home Assistant. I don’t see why that would be. The reason I know that the lights are capable is because I have an app on my Android phone called “Chromania” that strobes my lights to music with different colors based on beat and frequency.
I’ll try to figure out the script, but I’m not sure where to even start in order to have it change one step every time its executed rather than flowing through the colors every few seconds. The theory I have is that the remote will fire off enough events that the changes would look smooth anyway to the human eye. I just need to change the colors based on math equations.

Mazing!

Well done.

Using Sylvania zigbee bulbs. Transitions are smooth.

1 Like

@C.G.B.Spender Thank you so much for sharing!

What would be the best way to make the transition ultra slow. Let’s say I want the transition to be switched from one “full” color to the next in 15 minutes or so?

I’m already playing around with your yaml but haven’t nailed it yet.

I haven’t really found a way to alter the speeds, whenever I mess with them it’s not smooth. I just copied the script from the gist linked in 1st post, so maybe worth asking there too.

As I understand the script is made for the 1sec delay, to alter the speed you’d have to alter the number of colors too I think, but I don’t really get it.

I think I got the issue now:

since the color is chosen based on the times current seconds, this might not work

xy_color: '{{ colors[(now().second/2.5)|round(0)] }}'

I stumbled across this service call: Set a random color on a light
This does not use the current time to choose the color. I think this will work better for my desired outcome.

Thank you so much for getting me started on this. I finally see my Lounge Lighting about to happen :slight_smile:

Is there a way to control the brightness? Tried adding a brightness: 50 entry but the leds flash bright then quickly change to 50 brightness.

I’m not sure honestly.

I thought creating a default value for the light as described @ Light - Home Assistant would do it

I modified blueprint like so:

- service: light.turn_on
  data_template:
    brightness_pct: 50
    xy_color: '{{ colors[(now().second/2.5)|round(0)] }}'
    transition: 1
  target: !input 'cl_light'

then created light_profiles.csv next to where configuration.yaml is and for my light I created the defaults like so:

light.lightstrip.default,0.217,0.077,50

and restarted HA, which makes the lightstrip start at half brightness, but when the automation to loop starts it briefly goes to max brightness then to 50. No idea why.

No worries. We’ll see if anyone has found a fix.

I found this alternative option so going to try it

Ha! Just found this after making something similar but without hardcoded values. Thinking about making a component for general light effects instead now…