Power cycle needed after triggering a relay off->on ? What about the software watchdog?

@Karosm implies that the device being switched is causing serious electrical noise which causes the ESP to get “stuck”, or, in the other case, that there is too much load on the power supply. You should be able to emulate these conditions to confirm that that is what is happening.

If it is the former, then you’ll have to figure out how to reduce it’s noise.

In the latter, with a magnifying glass, look for cold solder joints (gray not shiny solder) or lifted leads and resolder appropriately.

A third possibility: While I use Tasmota as opposed to ESPHome, I had a similar situation where the configuration and/or code got into a funky state (couldn’t connect to MQTT broker). I had to reflash the code and reset the configuration. Restoring the configuration from backup did not fix my problem, but was fixed when I manually restored each attribute. Be aware, if this fixes the problem, your ESP devices has begun a death spiral.