Can I combine a status led and GPIO output?

I configured a Gosund SP111 with ESPhome and it works fine.

However, the device only has one LED and I know that with the Tasmota firmware (before ESPhome) the same LED could be used both for status (wifi connection, boot) and indication of relay status.

If I use the following config (trimmed, the rest is standard), I correctly see the LED blinking during boot and Wifi connection, but then it doesn’t react when I switch on and off the relay.

status_led:
  pin:
    number: GPIO13
    inverted: True 

output:
  - platform: gpio
    pin: GPIO13
    inverted: true
    id: led

switch:
  - platform: gpio
    pin: GPIO14
    id: relay
    name: '${plug_name} - Switch'
    icon: mdi:power-socket-eu
    on_turn_on:
      - output.turn_on: led
    on_turn_off:
      - output.turn_off: led

When I press the physical button I see the LED turning on for a brief moment and the relay activates, then the LED goes off and the relay as well.`

However, when I turn on the relay via the web interface of HA, the relay stays on and the LED doesn’t blink at all.

Can I combine the status led with the status indicator?

The issue with the physical button turning on and off immediately was due to the mistake:

binary_sensor:
  - platform: gpio
    id: button
    internal: true
    pin:
      number: GPIO0
    on_state:
      - switch.toggle: relay
    filters:
      - delayed_on: 10ms
      - delayed_off: 10ms

which should have been “on_press”.

The remaining issue stays.

Apparently it’s by design

1 Like