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:
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?