Wifi indicator in ESP?

Hi

Using some Sonoff devices I’d like to use one of the two LEDs of the device to indicate if Wifi is connected or not !
I was thinking about code like that below but it looks if can not be used this way :frowning: A turnaround to do that ? Have looked on esphome website and here but found nothing similar !

if:
  condition:
    wifi.connected:
  then:
    - switch.turn_on: led_wifi
  else:
    - switch.turn_off: led_wifi

Thanks for help,

Vincèn

Where you add that code? You need a trigger for it. e.g. Interval

# Example configuration entry
interval:
  - interval: 1min
    then:
      if:
        condition:
          wifi.connected:
        then:
          - switch.turn_on: led_wifi
        else:
          - switch.turn_off: led_wifi

Hi.

You could use

status_led:
  pin:
    number: GPIO13
    inverted: yes

instead of switch to be informed about the device’s status (including problems like no connection to the API while connected to WiFi).

Ah thanks it’s what I was missing, just a little confused by the fact you need a condition to put an other one :smiley: but working fine now with an interval of 1s :+1:

Yep very good idea but unhappy the behaviour of this indicator is not good for me, and there is no way to change it :frowning: I prefer to get status led full on when it’s working then completely off as you don’t know in this case if it’s dead/not powered or really working…