How do I get a colourful RGB LED strip with esphome?

Then again, the point of ha is to avoid a multitude of apps.

Wled’s app or webserver / esphome’s webserver + HA means redundancy!! when my HA server was crashing every other day, I had at least these two to rely on.

A lot of people have suggested WLED and it’s a great piece of software. The only issue I have with it is, it basically turns your esp board into a 100% led controller. For some people and some situations, that’s just fine. For me, I normally always need to use additional gpios or add sensors for different things and a 100% led controller makes that difficult. If you want to use your board for other things and not just for controlling an led strip, you need to look at FastLed or the neopixel bus. You can control dumb or addressable leds just like with wled and use a ton of effects. To individually assign a color to each led, you need to create Light Partitions. Also, do yourself a favor and go have a look around through the esphome docs. This is all part of the light component that you created, you just didn’t look hard enough. For your project your doing now, you may find wled works better because you only want a light controller but I highly recommend you try these out. Your going to find there a lots of situations where you want more than just an led controller and these are perfect for those times.

1 Like

It’s a $5 board. What is wrong with one dedicated to WLED?

I bought two of these controllers for WLED this year. Mostly because it is in a nice package.

IMO there is nothing wrong with WLED (I have multiple instances of it running throughout my setup). However, there are some benefits to using the esphome built-in led operations. As @Fallingaway24 mentioned above you can use the other pins for various functionality to compose an all-in-one solution without relying on home assistant or some other piece of software. For example I am setting up an esp32 with a nextion display, temp/humidity sensors, and leds. Using the display, I can see the values of the temp/humidity sensors, turn the leds on/off, and set the colors. I can also use the leds to display a different color on the strip if the temperature is too hot or if the humidity is too low. All of this can be done on the board with or without wifi and not being connected to any other systems.

2 Likes

The price of the board is 1 of many factors. Each board needs a psu, microUSB, enclosure, cable glands, more wire management, etc, etc. I don’t slap an esp on a breadboard and call it a finished project. Right now, aside from all of those factors. The number of esp boards on my network is close to 50 and it keeps growing. Did I mention I can do the same stuff without tying up a whole board?


1 Like

Hello Fallingaway, hello folks,

I’m tryin to upgrade a dumb keypad with an ESP32 and ESPHome, I did manage to succesfully use the Matrixkepad componnent and now I would like to add 3 more RGB leds (on of them should be kind of circular progress bar, so 8 leds for this one) for different status controlls and error handling. I have soldered 3 the stripes pieces to 3 GPIO pins 25,26,27 and used in the first try Fast Led the standard
code:

  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO23
    num_leds: 1
    rgb_order: GRB
    name: "NumPadLeft"

 # to be repated for the other two stripe pieces

I had issues controling it from HomeAssistant the delay was big and from time to time unresposive.
I found that this is a common issue, even the founder of ESP Home recomended to others to use NeoPixelBus.

I did a try, using the similar code. Pleas see bellow. The entities apeard corectlly in HA, but ony one is working and turning on all the other LEDs as well. So if I activate the “NumPadLeft” light, all will be turned on. In the case of fast led this was working well.

Any ideas why is this happening? Any sugestions or maybe other componets which I could use to integrate the 3 pcs of WS2812B separatelly into HA and have instant reaction?

Thank you all!

light:
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO27
    num_leds: 8
    name: "NumPadRing"

  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO26
    num_leds: 1
    name: "NumPadRight"
          
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO25
    num_leds: 1
    name: "NumPadLeft"

if a single light entity is turning on the other ones, you’ve likely got a wiring issue. Does each gpio go to a sperate strip? It sounds like you’ve got all of your data lines connected and they shouldn’t be. You also need to make sure you are using the correct terms. You mention an RGB light in one place but your code suggests your using addressable led’s. These are 2 different things, one is controlled by a single data(gpio) the other uses a gpio for each color channel, R,G,B so it uses 3 gpio’s.

Thanks Justin for your reply.

Sorry for the bad term usage. I was using RGB as common term. Indeed we speak about Adressable WS2812X led stripe with GRB sequence.
The wiring is correct, because the FASTLed component was adressing the LEDs corettly, it was just the unresponsivess issue in Home Assistant.

I between after a lot of googling I have found the issue with neopixelbus. In order to use separate GPIO pins, an adreess needs to be specified for each. Please see bellow. Somebody like me will need it :slight_smile:

- platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO26
    method:
      type: esp32_rmt
      channel: 1
    num_leds: 1
    id: NumPad_Right
    name: "NumPad_Right"
          
  - platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO25
    method:
      type: esp32_rmt
      channel: 2
    num_leds: 1
    id: NumPad_Left
    name: "NumPad_Left"

gotcha. I figured it was a wiring issue or how the lights were set up. I have a similar lighting setup and didn’t need to specify channels but I used the Partition integration to declare which gpio’s and how many led’s were in the light. I aslo used an esp8266 so that’s probably the difference.

I have one more questions.

When I’m turning on or off the neopixelbus LEDs ( via Home assistant eintity) by standard i got a dimm-up or a dimm-down effect, would say about 0.5 seconds. Is there a way to just turn the LEDs quickly on or off?

Edit: Found it. By default there is a transition time of 1 sec.
Instant on can be set with: default_transition_length: 0s

- platform: neopixelbus
    type: GRB
    variant: WS2812X
    pin: GPIO26
    method:
      type: esp32_rmt
      channel: 1
    num_leds: 1
    id: NumPad_Right
    default_transition_length: 0s
    name: "NumPad_Right"

Hello everyone. Maybe not the right place to ask (different topic) but I need help with code for 2 ws8212b strips, controlling by one esp32 board. When I leave one strip with one code for on/off it’s work fine, but when I add code for second strip , I have to turn on both switches on to control On/Off for strips. They are on the different GPIO’s. What I am doing wrong?

esphome:

  name: bed-occupancy-sensor

  friendly_name: Bed Occupancy Sensor

esp32:

  board: esp32dev

  framework:

    type: arduino

# Enable logging

logger:

# Enable Home Assistant API

api:

  encryption:

    key: ""

ota:

  password: ""

wifi:

  ssid: !secret wifi_ssid

  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails

  ap:

    ssid: "Bed-Occupancy-Sensor"

    password: ""

captive_portal:

   

binary_sensor:

  - platform: template

    name: "Bedroom2 Bed Occupied"

    id: br_o

    lambda: |-

      if (id(yevgeniy_side).state < id(trigger_level).state) {

        return true;

      } else {

        return false;

      }

sensor:

  - platform: adc

    pin: GPIO34  #Use a different pin for each FRS strip

    attenuation: 11db

    name: "Yevgeniy Side Sensor"

    id: yevgeniy_side

    icon: mdi:bed

    update_interval: 0.5s

    filters:

      - sliding_window_moving_average:

          window_size: 10

          send_every: 1

      - or:

          - throttle: 180s

          - delta: 0.02

  - platform: adc

    pin: GPIO35  #Use a different pin for each FRS strip

    attenuation: 11db

    name: "Irina Side Sensor"

    id: irina_side

    icon: mdi:bed

    update_interval: 0.5s

    filters:

      - sliding_window_moving_average:

          window_size: 10

          send_every: 1

      - or:

          - throttle: 180s

          - delta: 0.02

  - platform: homeassistant

    name: "Trigger Level"

    id: "trigger_level"

    entity_id: input_number.bed_trigger_level

light:

  - platform: fastled_clockless

    on_turn_on:

      then:

        - light.turn_on:

            id: yevgeniy_lights_light

            brightness: 25%

    chipset: WS2812B

    pin: GPIO22

    num_leds: 151

    rgb_order: GRB

    name: "Yevgeniy Lights"

    id: yevgeniy_lights_light

    default_transition_length: 0s

    color_correct: [50%, 50%, 50%]

    restore_mode: ALWAYS_off


- platform: fastled_clockless
    on_turn_on:
      then:
        - light.turn_on: 
            id: irina_lights_light
            brightness: 25%
    chipset: WS2812B
    pin: GPIO4
    num_leds: 151
    rgb_order: GRB
    name: "Irina Lights"
    id: irina_lights_light
    default_transition_length: 0s
    color_correct: [50%, 50%, 50%]
    restore_mode: ALWAYS_off

web_server:

  port: 80

Thank you

Looks ok to me. Are you sure it’s not a wiring issue? There are several warnings about issues with fastled in the docs. Is there a reason you aren’t just using neopixel which doesn’t have all those issues that haunt fastled?

The indentation for the two lights are different.

No it’s not a wiring issue, because it’s even happened when I disconnect one strip from the board but leave my code like it is. I bought this strips from Aliexpress long time ago and decided to use for my night light under the bed with bed sensor. It’s really good brand, BTF-Lighting. Thank you for your response.

What you mean, please explain
I copy and paste code from #1 to #2 , just change GPIO #

Just look at your yaml. The first is indented 2 spaces, the second is not.

I clean what I see, but still same issue, also it’s not turning my wife side lights on, only my with both triggers in on position

light:

#### My lights##

  - platform: fastled_clockless

    on_turn_on:

      then:

        - light.turn_on:

            id: yevgeniy_lights_light

            brightness: 100%

    chipset: WS2812B

    pin: GPIO22

    num_leds: 151

    rgb_order: GRB

    name: "Yevgeniy Lights"

    id: yevgeniy_lights_light

    default_transition_length: 0s

    color_correct: [50%, 50%, 50%]

    restore_mode: ALWAYS_off

#### Irina's Lights#####

  - platform: fastled_clockless

    on_turn_on:

      then:

        - light.turn_on:

            id: irina_lights_light

            brightness: 100%

    chipset: WS2812B

    pin: GPIO23

    num_leds: 151

    rgb_order: GRB

    name: "Irina Lights"

    id: irina_lights_light

    default_transition_length: 0s

    color_correct: [50%, 50%, 50%]

    restore_mode: ALWAYS_off    


Here is my wiring diagram. I use ESP32 and logic shifter ( for LED)
Gpio22 connected to LV4 on Logic shifter, GPIO23 to LV2 and HV4 to Yevgeniy LED, LV2 to Irina LED
I share the ground for both of them . 5v going directly to LED strips ( separately)

For a start restore_mode: ALWAYS_OFF (not ALWAYS_off) see Light Component — ESPHome.

And we cannot really see that so called wiring diagram. Please just draw it on a piece of paper. Label the components.