esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
411 stars 26 forks source link

Use RGB led as status led #2230

Open exico91 opened 1 year ago

exico91 commented 1 year ago

Describe the problem you have/What new integration you would like

Some ESP boards have a RGB led instead of a "dumb led". Its not possible to use a RGB led as a status led at the moment. It would be nice if we can set a RGB led as status led, maybe with a fixed color.

Please describe your use case for this integration and alternatives you've tried:

Some boards that have a RGB light instead of a normal led are: (not exaustive, these are the ones that i know of) Wemos S3 Mini, S3, S3 PRO, C3 mini v2, C3 pico. The only option now is to wire an external led on those boards if you want a status led

Additional context

I'm repeating myself but it would be nice to have a rgb light as a functional status led, even with a fixed color. Would that be feasible?

kaechele commented 1 year ago

Would #1603 do what you want?

ssieb commented 1 year ago

You can use https://esphome.io/components/light/status_led.html with a template output that sets the state of the RGB LED.

exico91 commented 1 year ago

Would #1603 do what you want?

Not really, from what I understand you can use the rgb light for different events. What i want is the same behavior as: status_led: pin: somepin IDK, maybe choose a color/intensity and use that for the status_led

You can use https://esphome.io/components/light/status_led.html with a template output that sets the state of the RGB LED.

Can you elaborate please?

ssieb commented 1 year ago
output:
  - platform: template
    id: status_output
    type: binary
    write_action:
      - if:
          condition:
             lambda: return state > 0;
          then:
            - light.turn_on:
                ... red
          else:
            - light.turn_on:
                ... green
exico91 commented 1 year ago

Hello,

sorry for the wait, I just acquired some wemos C3 mini v2 with the RGB and I was testing them out.

From what i understand the complete code will be something like this:


light:
  - platform: status_led
    name: "status led"
    output: statusoutput
  - platform: neopixelbus
    variant: WS2812
    pin: 7
    num_leds: 1
    name: "Status LED RGB"
    id: statusledlight
    icon: "mdi:led-outline"

output:
  - platform: template
    id: statusoutput
    type: binary
    write_action:
      - if:
          condition:
             lambda: return state > 0;
          then:
            - light.turn_on: 
                id: statusledlight
                red: 1.0
                green: 0.0
                blue: 0.0
                brightness: 30%
          else:
            - light.turn_on: 
                id: statusledlight
                green: 1.0
                red: 0.0
                blue: 0.0
                brightness: 30%

I added some adjustments, it was too bright otherwise.

The light stay on a solid green. There is a way to simulate an error? I would like it to change color in two occasions:

  1. When the wifi connection is lost
  2. Since i use these C3 mini as bluetooth proxy i would like it to blink blue when there is a bluetooth transmission, would that be possible?
jhenkens commented 11 months ago

On an lolin_s3_mini, I used the following to calm down the log, and actually make it strobe. Key differences - 50ms transition length, and adding conditional setting via a proxy template switch.


light:
  - platform: status_led
    id: status_light
    output: status_output
  - platform: neopixelbus
    id: esp32s3_rgb_led
    name: Status RGB LED
    type: RGB
    variant: 800KBPS
    pin: 47
    num_leds: 1
    icon: mdi:led-outline
    entity_category: config
    restore_mode: ALWAYS_OFF
    method:
      type: esp32_rmt
      channel: 0          

switch:
  - platform: template
    id: status_led_switch
    # name: "Status LED Switch"
    optimistic: true
    on_turn_on:
      - light.turn_on: 
          id: esp32s3_rgb_led
          red: 100%
          green: 0%
          blue: 0%
          brightness: 30%
          transition_length: 50ms
    on_turn_off:
      - light.turn_off: 
          id: esp32s3_rgb_led
          transition_length: 50ms

output:
  - platform: template
    id: status_output
    type: binary
    write_action:
      - if:
          condition:
             lambda: return state > 0;
          then:
            - if:
                condition:
                  switch.is_off: status_led_switch
                then:
                  switch.turn_on: status_led_switch
          else:
            - if:
                condition:
                  switch.is_on: status_led_switch
                then:
                  switch.turn_off: status_led_switch

I still think enabling arbitrary backing lights, rather than just an output, would be good.

strzegus commented 6 months ago

Has anyone tried to control the built-in RGB LED on the ESP32-S3-DevKitC-1 board in ESP HOME?

randybb commented 6 months ago

@strzegus There are many clones of the original board https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html - on the original board is the addressable RGB led connected to GPIO38, so basically you can use the previous config, just change pin: 47 to pin: 38. Based on it's schematics there is SK6812.

nielsnl68 commented 6 months ago

I create a component based on the current status components that allows you to create scripts for every status including your own. https://github.com/esphome/esphome/pull/5814 Could that resolve your question?