#Helper to define a preset color for a RGB light

1 messages · Page 1 of 1 (latest)

viral moss
#

I want to define helpers on a configuration dashboard that can be used to preset color and brightness for a LED strip.

The idea is to use a color picker on the dashboard that allows to select color and brightness which is then stored in the helper.
Then create an automation that if triggered assigns the preset color to the LED.

I see a lot of similar questions on various forums but they are dated to '22 and before and do not provide a simple and straight forward solution. Not sure if since then things have changed and new functionality to build this has been added.

Looking forward to your suggestions, thank you in advance

lost hawk
#

Are you trying to set presets to allow you to save the colour/brightness and then switch between them?

viral moss
#

Yes, and I want to do this using a color picker on a separate "config" dashboard.
I have a LED strip that has two functions, tradional light and alerting. For both functions I want to be able to define the color on the config page.

For example:
Helper_1 : normal color (255,255,255) Set by color picker 1
Helper_2: alert color (255,0,0) Set by color picker 2

Automation_1_normal:
Turn on LED, set color to helper_1

Automatio_2_a;ert:
Turn on LED, set color to helper_2

lost hawk
#

For what you want, you'd need to make one of those for each state you want and change the "set_rgb" action to save the current rgb value of into your input_text helper somehow (probably just | join(',') would work fine) - you might actually be able to get away with only one "setting" template light if you also have a selector between various input_texts to save into but idk

#

However I haven't tried this and don't have any rgb lights to test with

viral moss
#

Thanks for the suggestion! I was hoping for an easy config but this will take a little more time. Will test over the weekend and report back.

lost hawk
#

good luck

viral moss
#

Investigated the Light-template route and to be honest it was a little above what I feel comfortable with but it lead me into the right direction.
I now have a working solution based on a HACS integration and some additional templates,
I am sharing the basic configuration in case anybody is intrested.

1. HACS - Virtual components
Defined two virual lights to be used as preset in the config.yaml file:

# Virtual lights used to pre-set LEDstrip
light:
  - platform: virtual
    name: "LEDstrip Motion LEFT preset "
    support_color: true
  - platform: virtual
    name: "LEDstrip Motion RIGHT preset "
    support_color: true

2. HACS Light entity card
Added two light entity cards to the dashboard , configured to show a Color wheel

**3. Created an action in my automation that copies the RGB and Brightness values from the virtual preset and turns on the LEDstrip **

sequence:
          - data_template:
              entity_id:
                - light.esp_15_neopixel_light_01
              rgb_color: >-
                {{
                state_attr("light.virtual_ledstrip_motion_right_preset","rgb_color")
                }}
              brightness: >-
                {{
                state_attr("light.virtual_ledstrip_motion_right_preset","brightness")
                }}
            action: light.turn_on

Thanks for the help!

lost hawk
#

virtual components is good to know about

#

glad you got something working

young rover
#

You could also have used scenes for this. Setup a scene for each color, and switch between them

viral moss
#

That's what I have considered at first but I have tried that on another project about 6 months ago and it was not successfull. Hoping things have improved overtime, I gave it another try but found they were not reliably applied. Without a real reason the scenes were not always applied, especially if you create a scene from an automation. .
The solution I have described above is now running for multiple days with 100% success rate.

Thanks for your suggestion!

glossy ginkgo
#

Can't you just do this?

  - action: light.toggle
    metadata: {}
    data:
      brightness_pct: 100
      rgb_color:
        - 255
        - 255
        - 255```
Unless you're going to be regularly changing what colours for helper 1 and helper 2 but i imagine its white light for normal and red late for Danger, Will Robinson?