How to blink a single LED at random intervals?

I am building a project that measure power consumption from a blinking LED. A variation of this super good project: GitHub - klaasnicolaas/home-assistant-glow: ⚡ The power of energy measurements in your house.
In order to test the setup I need a “blinking” LED to simulate real life condition. For testing I need af short blink randomly every 1-3 seconds.
I did this to blink shortly every 1 second, but how do I make it random?
switch:

  - platform: gpio
    name: GPIO D32
    id: gpio_d32
    pin:
      mode: output
      number: GPIO32
      inverted: true

interval:
  - interval: 1s
    then:
      - switch.turn_on: gpio_d32
      - delay: 1s
      - switch.turn_off: gpio_d32
      - delay: 1s

Best regards,

Vagn Petersen

You could define it as a light rather than a GPIO output.

One if the supported features of the Light component is random: - not sure if it is supported for binary lights or not but have a play.

Yes, I looked at that option too. But I think the random part is only for color and/or transition??

Bummer. My only other thought was to try a random function in lambda to generate the delay, but a quick google shows limited or no success - the only example I could find came up against compile errors.

You could use a light effect for a binary light, there’s random one:

Solved the problem in a little different way :slight_smile:
I used Node Red from Home Assistant to turn on the LED for 200ms, turn it of and wait for a random time interval (between 0.5 sec and 5 sec.) and then repeat the sequence.