Rescuing bricked bulb due to on_boot infinite loop

I flashed my light bulb OTA but I got it bricked with a stupid script :slightly_smiling_face:

Now when I turn on the physical light switch, the light bulb will turn on for 0.5s and turn off itself.
Wifi is not connected before on_boot is called.

I tried to enter safe mode by toggle on/off for 20+ times within 1-2s with a smart plug but no luck.
1 out of 30 times I could get it skip on_boot (i.e. no light on and stay off after switch is on).
However, the bulb is not connected to home wifi and no AP is observed.

I hope priority: -10 and delay: 500ms could buy me a few time to interrupt the on_boot calls but seems impossible.
Anything else I can do? Should I just give up?

substitutions:
  entity_id: "my_owner_is_a_dumb"
  esphome_node_name: "light"
  friendly_name: "Light"

esphome:
  name: ${esphome_node_name}
  friendly_name: ${friendly_name}
  on_boot:
    priority: -10
    then:
      - light.turn_on: ${entity_id}
      - delay: 500ms
      - light.turn_off: ${entity_id}

esp8266:
  board: esp01_1m

output:
  - platform: esp8266_pwm
    id: output_brightness
    pin: GPIO13
  - platform: esp8266_pwm
    id: output_temp
    pin: GPIO14

light:
  - platform: color_temperature
    id: ${entity_id}
    brightness: output_brightness
    color_temperature: output_temp
    warm_white_color_temperature: 2700 K
    cold_white_color_temperature: 6500 K
    default_transition_length: 0s
    restore_mode: RESTORE_DEFAULT_OFF
    on_turn_off:
      then:
        - light.turn_off:
            id: ${entity_id}

logger:
  baud_rate: 0

api:

ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  min_auth_mode: WPA2
  ap:
    ssid: ${friendly_name}
    password: !secret ap_password

captive_portal:

Doesn't make sense. What are you trying to accomplish and with what bulb?
Use of GPIO10 is raising red flag to me, it's usually connected to flash chip.

Thanks for reply.
What I wanted to do in on_boot is for notifying me after the flash is done.
on_turn_off is added during the progress of resolving the LED bulb faintly lit issue after turning off.

I just randomly picked the number. The original pins should be 13 and 14.

I'm pretty sure the device has entered safe mode but no wifi connected.

However, I used ESPHome with the version earlier than 2026.4.5 to flash my device and it looks like I'm the victim of safe_mode not working · Issue #16262 · esphome/esphome · GitHub.

Unlikely but is it possible for me to force connect wifi connection to the device?

So you posted a code that is not what you really uploaded? Or you uploaded it with Gpio10?
Also, again, what bulb? How you flashed it?
What makes you think it "turns off itself "? Your code just turns the light off.
Also, what's the point of this "loop"?