ESPHome - how to ota ESP sensor in deep sleep over MQTT

I created initial configuration of ESP sensor and uploaded it over USB with epshome python command tool. It then wakes up for few seconds and goes to deep sleep for several minutes.

How do I then ota from command line over mqtt? Or do I somehow need to ota from Home Assistant GUI? I can ota when I press reset on ESP chip and start “esphome …yaml upload” at the same time, but in production I may not have physical access to the sensor, so I need to wait until it wakes up and fetches ota notification from broker over mqtt.

Thanks, Jan

I think I saw this dealt with something like this:

Create a mqtt topic like device/wantota

Subscribe to that topic on the esp, and if it is true suspend sleep

When you want to ota a new firmware, publish true to device/wantota and wait for the next waleup.

Try this thread Need Help setting up deepsleep.prevent

1 Like

Well, thank you very much, your advice will come handy after few weeks when I leart to “create topic”, “subscribe to topic”, “publish to device”… :slight_smile: Thank you very much.

One thing still not completely clear to me: I can switch ESPHome to “deep sleep dsabled” state, which will happen several hours after I order it to by mqtt message. But how is then ota pushed to ESPHome? Do I need to push it manually, or can HA send it automatically when it discovers that ESPHome is online? I did not find that code anywhere.

You could automate, using the esphome commandline, but I kinda feel you wouldn’t be doing this often enough to bother.