WiFI LED Indicator does not restore state

I have a wifi LED status indicator,

When connected, the LED displays GREEN at 100% which is correct.
On disconnect, the LED flashed red at 100% brightness, which again, is correct.

However, when the ESP reconnects to the network, the LED does not return to the GREEN state but rather continues to flash RED in the error state.

Any idea why this could be hapenning?

Thanks

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password
    bssid: xx:xx:xx:xx:xx:xx
  fast_connect: true
  on_connect:
    - light.turn_on:
        id: led
        brightness: 100%
        red: 0%
        green: 100%
        blue: 0% 
  on_disconnect:
      - light.control:
          id: led
          state: on
          effect: ERROR
####Status LED Start####
light:
  - platform: fastled_clockless
    id: led
    name: "LED"
    pin: 23
    chipset: WS2812
    num_leds: 1
    rgb_order: GRB
    restore_mode: ALWAYS_OFF
    effects:
      - lambda:
          name: "ERROR"
          update_interval: 0.2s
          lambda: |-
            static bool state = false;
            auto call = id(led).turn_on();
            call.set_transition_length(500);
            call.set_rgb(1, 0, 0);
            if (!state) {
              call.set_brightness(1);
            } else {
              // If using 0, it freaks Home Assistant UI.
              call.set_brightness(0.01);
            }
            call.perform();
            state = !state;
      - lambda:
          name: "BOOT"
          update_interval: 0.2s
          lambda: |-
            static bool state = false;
            auto call = id(led).turn_on();
            call.set_transition_length(500);
            call.set_rgb(0, 1, 0);
            if (!state) {
              call.set_brightness(1);
            } else {
              // If using 0, it freaks Home Assistant UI.
              call.set_brightness(0.01);
            }
            call.perform();
            state = !state;
####Status LED END####

What happens if you add effect: none to the on_connect: block?

  on_connect:
    - light.turn_on:
        id: led
        brightness: 100%
        red: 0%
        green: 100%
        blue: 0% 
        effect: none
1 Like

I will try this and let you know.

Thanks

You are the man!

This seems to have sorted it. Well done!

Thanks

1 Like