I had an IKEA Vindriktning with an ESP-01 module in it that went missing during our hurricane recovery two years ago. This week it turned up in a crate under the sink. It still appeared in Home Assistant, but I had deleted it from the ESPHome, so I assumed the YAML was gone.
When I plugged it in, it gave no visible sign of life, but it was on the network. What follows is how I got the original config back without touching the device, and what I would have done if the config really had been gone.
TL;DR: As of ESPHome 2026.6.0 the ESPHome dashboard doesn't actually delete your YAML. It moves it to /config/esphome/archive/. Look there first. Everything else in this post is for when that folder is empty.