[SOLVED]/Improving Color Loop

Before we get to that, what transition time do you want between colours?

I don’t think you need more colours (fading between 25 colours should be plenty), you just need to adjust the template for the transition time you want.

So lets try fixing that first.

Let’s say 60

One minute between colours?

Ok you just made that easy, I think. Let me try it…

Try this:

  sequence:
    - service: light.turn_on
      data_template:
        xy_color: |
          {{  colors[(now().minute/2.5)|round(0)] }}
        transition: 55 # not quite sixty seconds, just to make sure the transition finishes before the next colour command
        entity_id: '{{ entity }}'

I got the transition wrong, sorry

This is what I want to archive. See Video

That’s a very fast transition. You are going to be better off with a LED controller that supports a rainbow effect. Otherwise you will be flooding your network with commands and loading Home Assistant.

Tuya has stopped supporting rainbow scene effect in home assistant. Leaving the network problem out. Is it possible to do?

Yes, with a new light controller.

An ESP32 flashed with WLED will cost you $5.

Can you send a link for buying the ESP32, amazon or something?

https://www.aliexpress.com/item/32817842070.html

And the link to WLED:

It has more effects than you will ever use. Lots and lots of colour pallets (as well as custom), and it integrates very well with Home Assistant.

Is there a pre populated version of this where you can just connect power and led strip.

Yes, prebuilt and pre-flashed with WLED, but it will cost you more (stock should be arriving soon):

how can I add this script to my setup? I was able to add the automation but the script gives me errors when I try to copy and past its yaml in the script page. I feel like its formatted differently?

Just curious…what would it be for 30 seconds?

Hello! I also tried this and checked really everything but it doesn’t work :confused: I have the same config but my light doesn’t even turn on.
Can someone help me? It’s a Paulmann Cube, but supports xy, rgb and hs color.

thx in advance!

Hi all,
I want to use this script to change the color of a rgbw led strip by holding down a button and when the button is released, stay on that color. Is there a way to change to all colors in lets say 10 seconds?
That would be really nice.
Using:
xy_color: |
{{ colors[(now().second % 25)|round(0)] }}
give me all colors in 24 seconds, but I want it faster.

It would even be more useful if we could set the cycle time by giving it as a parameter to the script!
Who can help?

Hi all,
First of all, I applaude tom_l for patiently answering all these questions. I am still super new to HA and wanted to give it a go myself. Since LIDL had a sale of the smart home devices including lamps, I purchased some for testing purposes. The light I am using is an E14 RGB candle light by Silvercrest and the connection via ZHA worked like a charm.
Testing the script was very straight forward, but I wanted to have a switch that would toggle between the rainbow mode and warm white of the bulb. I was playing around with the “repeat” action and got to the final solution after figuring out the proper order of syntaxes. As a toggle I used a input boolean helper.

- alias: Stern Rainbow Mode an
  description:
  trigger:
  - platform: time_pattern
    hours: '*'
    minutes: '*'
    seconds: /1
  condition:
  - condition: state
    entity_id: input_boolean.rainbow_mode
    state: 'on'
  action:
  - repeat:
      until:
      - condition: state
        entity_id: input_boolean.rainbow_mode
        state: 'off'
      sequence:
      - service: script.rainbow_light
        data:
          entity: light.licht_rgb_lidl_level_light_color_on_off
  - service: light.turn_on
    target:
      entity_id: light.licht_rgb_lidl_level_light_color_on_off
    data:
      kelvin: 2000
      brightness_pct: 100
  mode: single

This works flawlessly, however, the LIDL lights are very dim in RGB mode compared to the warm to cold white. Also my girlfriend is not a fan of RGB - but it was a fun project anyways.

1 Like

Hi @JottHa , please change "description: " to "description: ‘’, was throwing an error on my side.

THX

The automation’s 1-second Time Pattern Trigger is an inefficient use of Home Assistant’s resources. Basically, it’s polling the input_boolean every second (regardless if the input_boolean’s state is on or off).

Given that the goal is to execute the automation’s action only when the input_boolean is on, simply use a State Trigger.

- alias: Stern Rainbow Mode an
  description:
  trigger:
  - platform: state
    entity_id: input_boolean.rainbow_mode
    from: 'off'
    to: 'on'
condition: []
  action:
  - repeat:
      until:
      - condition: state
        entity_id: input_boolean.rainbow_mode
        state: 'off'
      sequence:
      - service: script.rainbow_light
        data:
          entity: light.licht_rgb_lidl_level_light_color_on_off
      - delay: '00:00:01'
  - service: light.turn_on
    target:
      entity_id: light.licht_rgb_lidl_level_light_color_on_off
    data:
      kelvin: 2000
      brightness_pct: 100
  mode: single

In addition, include a small delay within the repeat otherwise it will loop as fast as the host machine’s CPU can execute the actions within the repeat (i.e. very fast).

2 Likes

THX - usefull improvement!