ESPHome offline behavior - best practices

ESPHome devices are expected to be connected for most of the time and start rebooting when that is not the case (WiFi down, no API connectivity, no connection to MQTT server, …). But what if being ‘offline’ is the expected situation, and ‘online’ the exception? How can ESPHome powered devices be configured to gracefully handle offline situations without constantly rebooting?

Yes, there is the option of preventing rebooting (reboot_timeout: 0s), but that has significant side effects and may cause the device to become unresponsive or never again connect. So, what are the best practices for dealing with a situation like this? Ideally, ESPHome devices do their thing while being offline without complaints, and gracefully reconnect whenever WiFi becomes available.

What is the use case, you ask? I’m running Home Assistant in an RV. When the RV is in storage, I do not want to run HA, my ethernet switch, WIFI router, and LTE modem 24/7 because that consumes way too much energy. Instead, all these devices will be turned off for, say 20 hours per day, and on for only 4 hours, so I can remotely monitor battery, systems, perform maintenance, etc. All my ESPHome devices still get power, including the ESPHome relay (Shelly 1) that is programmed as a timer and shuts down HA at predefined times for a predefined duration.

Is there a reason the esps remain powered? You could use the the deep sleep component. Although, I believe you would need to physically wire to one of the pins to wake on demand.

A few comments:

1/ Some esps are sitting on an electrical circuit that includes my Victron energy system (solar, battery charger, etc.). I can’t turn those off. Also, the esp timer that’s responsible for powering HA on/off obviously needs to stay powered on.

2/ Deep sleep looks interesting. But connecting GPIO 16 wire to RST is a problem because some Shelly devices use GPIO 16 for power measurement. Also, GPIO 16 is not readily exposed on Shelly. It’s interesting though that you can set run duration and sleep duration. It would be pretty cool to sync schedules so that while HA is off, all ESP devices are in deep sleep. When HA wakes up, so do the ESP devices.

3/ Maybe a way around this is to program an ESP reboot automation on a schedule that is synced with HA on/off timing? So, when HA starts up, all ESPs reboot, and then stay on throughout the day (with reboot_timeout: 0s) until the next time HA starts up again. It would still be a problem if they were to become unresponsive though (especially the timer).

Since I cannot find a good entry to ask this question and for some reason I cannot create a new entry, here it goes. Why does Home Assistant constantly list my esphome devices as offline even though they are sending/receiving data from Home Assistant? How do I prevent this? Am I forced to physically power down and power up each device daily/weekly?

@antcara You should start a new thread instead of continuing a new one here, it is not even related…

but anyway, seems you have a mDNS issue in your local network.
Several options:

  • fix mDNS
  • use static IP’s for Esphome devices
  • introduce a local domain name, so normal DNS will take over

and ps:
The Esphome addon has nothing to do with the esphome integration, it is just a tool to flash the devices, after that you could even shut it down, and the integration will continue to work :wink: