Looking for an asymmetric led pulse effect

I am working on an Access Control Unit, with a RFID sensor, RGB status led and Buzzer.
I have several states of the led and buzzer, depending on some trigger inputs like a RFID tag and a door sensor.
To control the different states of the led and buzzer I created several Scenes in HA that set the led color and pulse effect, and the buzzer beeps.
This is all working pretty nice up to now, but I now want to add an asymmetric led pulse effect like this:

AsymmetricPulse

So the led should be on for a long time, and off for a short time.
As I understand it, this is not possible with the default Pulse effect: the ā€œupdate_interval ā€œ and ā€œtransition_lengthā€ will always give a symmetric effect (the on duration is identical to the off duration).
I tried to do this with a lambda, but am unsuccessful up to now.
My last trial was this:

light:
  - platform: rgb
    name: "D1V3-02 RGB-led"
    id: d1v3_02_led_rgb
    red: output_red
    green: output_green
    blue: output_blue
    effects:
      - pulse:
          name: "Fast Pulse"
          transition_length: 0.1s
          update_interval: 0.4s
      - pulse:
          name: "Slow Pulse"
          transition_length: 1s
          update_interval: 2s
      - pulse:
          name: "Very Slow Pulse"
          transition_length: 1s
          update_interval: 4s
      - lambda:
          name: "Asymmetric Slow Pulse"
          update_interval: 5s
          lambda: |-
            auto call = id(d1v3_02_led_rgb).turn_on();
            call.set_transition_length(100);
            sleep_for(450);
            call = id(d1v3_02_led_rgb).turn_off();
            call.set_transition_length(100);

But the C++ ā€œsleep_forā€ (and also ā€œsleepā€ for that matter) are not accepted by ESPHome (ā€˜sleep_forā€™ was not declared in this scope), and I now understand that it is not sound anyhow to use any kind of Delay in lambdas.

Does anybody have a suggestion how to implement this?

1 Like

OK, so I think I found the solution myself.
It appears to be possible with the ā€œStrobeā€ effect:

light:
  - platform: rgb
    name: "D1V3-02 RGB-led"
    id: d1v3_02_led_rgb
    red: output_red
    green: output_green
    blue: output_blue
    effects:
      - pulse:
          name: "Fast Pulse"
          transition_length: 0.1s
          update_interval: 0.4s
      - pulse:
          name: "Slow Pulse"
          transition_length: 1s
          update_interval: 2s
      - pulse:
          name: "Very Slow Pulse"
          transition_length: 1s
          update_interval: 4s
      - strobe:
          name: "Asymmetric Slow Strobe"
          colors:
            - state: true
              brightness: 45%
              red: 0%
              green: 100%
              blue: 0%
              duration: 4600ms
            - state: false
              duration: 400ms

The only slight disadvantage here is that it seems that a ā€œtransition_lengthā€ is not possible with the Strobe effect, so the on/off transition is now very abrupt.
But I can live with that.

And another issue is that the color of the RGB led does have to be defined in the Strobe effect itself.
For the Pulse effects that is done in the HA Scene setup.
But again, I can live with that.

Any comments or suggestions?

1 Like

The led indeed is working as intended now, so since there were no comments or suggestions for other solutions, I have marked my second post as solution for the issue.

Hello, i am searching for a similar solution but i need to change to color ā€˜on the flyā€™ and this strobe effect always lights in white color if i donā€™t set the RGB values inside.
Pulse effects work with the selected colors on the home-assistant GUIā€¦
any suggestions?

i agree, I had a similar case - and the first thought was, to use the ā€œpulseā€ effect.
Strobe seems a bit off, because you need to set colors etc.

I would really appreciate, when both effects could be combined / inherited - so that you can either configure colors within the pulse, or configure the pulse with different on / off settings - or that you can ignore color settings on strobe / set transition lengths in the strobe effect.

1 Like

Hey, I found a potential solution for blinking the RGB LED via another switch template. It is not yet ready but it works if I set the RGB color in the main RGB LED button and switch on the template switchā€¦

Maybe it will help you with further work.

# Switch for blinking colorful temperature led
# Turn_on_action goes to a loop for switching rgb_light (id)
switch:
  - platform: template
    name: "Temperature LED blink"
    id: temp_led_template
    optimistic: true
    turn_on_action:
    - while:
        condition:
          lambda: 'return true;'
        then:
        - light.turn_on: rgb_light
        - delay: 1s 
        - light.turn_off: rgb_light
        - delay: 5s
    turn_off_action:
    - light.turn_off: rgb_light

# Example configuration entry
light:
  - platform: rgb
    name: "Living Room Lights"
    red: output_component1
    green: output_component2
    blue: output_component3
    id: rgb_light
    effects:
      - pulse:
          name: "BME Error Pulse"
          transition_length: 50ms
          update_interval: 0.1s
          min_brightness: 0%
          max_brightness: 100%
  

image