Is it possible to turn on/off wifi conditionally?

I want to run a battery powered door open/closed sensor using ESPHome. I’m going to use the deep sleep mode, but in addition to that, since WIFI is the largest power drain, I want to only connect to WIFI and send status to my HA instance if the door open/closed status has changed (and if it hasn’t go back to sleep). Is this possible to do?

Pretty sure deep sleep will do exactly that. You use the door sensor as the interrupt from deep sleep.

Perhaps I’m doing it wrong, but at the moment my door sensor is a linear Hall-effect sensor (well it’s actually a lock closed sensor, not door). I’m guessing your suggestion could work with a reed sensor instead?

The hall effect sensor should work too if it’s providing a simple open/close contact.