How to blink led on an ESP output in ESPHome integration

Hi,
I’m trying to have a led blink when a GPIO is set high. (don’t want to see this output in HA frontend)
Currently the led turns on or off, depending on the switch state. I’ve seen / read and tried different ways on some topics, but these where mainly based on pulsing a switch. (which causes logs in HA)

I’ve read the docs Slow PWM Output — ESPHome but it does not work.
I want to have a led blink on the enclosure as a physical indication when the valve is open.

esp8266:
  board: nodemcuv2
  framework:
    version: recommended

switch:
  # Switches
  - platform: gpio
    name: "Valve 4"
    id: valve4
    pin: GPIO15
    icon: mdi:pipe-valve
    on_turn_on:
    - delay: 500ms
    - output.turn_on: OpenValve1
    on_turn_off:
    - output.turn_off: OpenValve1
          
output:
  - platform: slow_pwm
    pin: GPIO04
    id: OpenValve1
    period: 10s

What am I doing wrong here?

You can try it like this

esp8266:
  board: nodemcuv2
  framework:
    version: recommended

switch:
  # Switches
  - platform: gpio
    name: "Valve 4"
    id: valve4
    pin: GPIO15
    icon: mdi:pipe-valve
          
output:
  - platform: gpio
    pin: GPIO04
    id: OpenValve1


interval:
  - interval: 1s
    then:
      if:
        condition:
          swtch.is_on: valve4
        then:
          - output.turn_on: OpenValve1
          - delay: 500ms
          - output.turn_off: OpenValve1
        else:
          - output.turn_off: OpenValve1
2 Likes

Hi Pepe59,
thx for the quick code update. I see the logic (which I was not able to distill from the esphome site)
this works as I expected. thx! I learned today :slight_smile:

easiest way I am aware of is just to use the pulse light effect :bulb:

light:
  - platform: ...
    effects:
      - pulse:
          name: "Blink"
          transition_length: 0s
          update_interval: 1s
2 Likes

Hi @orange-assistant,
sorry for my late response.
As mentioned, the solution from @pepe59 works fine, but for testing and directions, I tested yours anyway.

When adding this code:

light:
  - platform: gpio
    effects:
      - pulse:
          name: "Blink"
          transition_length: 0s
          update_interval: 1s

Its "complaining: Platform not found: 'light.gpio'.

That’s probably because there simply is no “gpio light:stuck_out_tongue:

Maybe you want to use a “binary light” instead? :point_down:

Check the docs for all light components :bulb:

I have three or four conditions that require different indicators shown by the onboard LED. The Interval blocks solved my problem perfectly. I tried the Pulse effect with different Light platforms, but each time, I got the error about the platform not supporting Pulse. I couldn’t find anywhere in the docs describing which platforms support Pulse, so I gave up on that.