Posting by request from https://www.reddit.com/r/homeassistant/comments/1hufw9c/i_got_my_shellys_to_keep_working_in_case_of_a/
My ESPHome file is higly modularized with a lot of other functionality that is not relevant right now, so here's an extract of the relevant bits. It's a bit more verbose than usual because it's the output of ESPHome validation process, which dumps the processed YAML after "expanding" it.
Context:
- light switch is a Shelly, but not really relevant — any ESP relay with a button would work
- connected to the relay are smart lights talking Zigbee
- when switch is "smart", relay remains on all the time and switch talks to HASS that turns on/off the light accordingly