Select component to control color of led strip (or anything else)

Hi,

After too much time spent on this, i cannot make this work. Just want to have a select template to control the color of a led strip.
I had a look at :

but no success

light:
  - platform: fastled_clockless
    chipset: WS2811
    pin: GPIO23
    num_leds: 3
    rgb_order: GRB
    name: "led_strip"
    id: led_strip

number:
  
  - platform: template
    name: "LED brightness"
    optimistic: true
    min_value: 0
    max_value: 100
    step: 1
    id: led_brightness



select:
  - platform: template 
    name: "menu"
    options:
      - "Rouge"
      - "Vert"
      - "Bleu"
    optimistic: true
    initial_option: "Rouge"
    # restore_value: true
    id: menu
    on_value: 
      then:
        - logger.log: "dans le then"
        - if:
            condition:
              lambda: |-
                return id(menu).active_index() == 0;
            then:
              - logger.log: "dans le if rouge"
              - light.turn_on: led_strip
              - light.addressable_set:
                  id: led_strip
                  range_from: 0
                  range_to: 2
                  color_brightness: !lambda |-
                      return 1*(id(led_brightness).state * 0.01);
                  red: 1
                  green: 0
                  blue: 0
        - if:
            condition:
              lambda: |-
                return id(menu).state.c_str() == "Vert";
            then:
              - logger.log: "dans le if vert"
              - light.turn_on: led_strip
              - light.addressable_set:
                  id: led_strip
                  range_from: 0
                  range_to: 2
                  color_brightness: !lambda |-
                      return 1*(id(led_brightness).state * 0.01);
                  red: 0
                  green: 1
                  blue: 0

Did you verify the light works before trying this?

1 Like

The values for the light.addressable_set action parameters red, green and blue
must be expressed in percentages (see documentation) like so:

  - light.addressable_set:
      id: my_light
      range_from: 0
      range_to: 50
      red: 100%
      green: 0%
      blue: 0%

Also, as pointed out above: did you verify the rest works as expected? Your code is quite complicated. Try to make a much simpler version (e.g. default color red, on a menu option change, then set the color to green). If that works, you can continue to add small layers of complexity and see what causes the code to break.

1 Like

No. They dont. Read the documentation.


People have been having all sort of trouble lately with FastLed. Id switch to Neopixel and first verify the light is wired and workint correctly before anything as that seems to be a common issue too.