WTH ESPHome can't handle firmware updates automatically for deep sleep devices

It would be great if ESPHome automatically handled updates for devices that go to sleep.
It could work something like this:

  1. In ESPHome - mark device to auto-update next time it is online
  2. on the device itself have a config section that would say, next time you are online (or once a day or at specific time, or once a week, etc) check with the server if there are updates and if they are install them then go to sleep.
    I know that there are workarounds involving MQTT or scripts but this should not be this complicated.

Or an alternative, would be nice if you could call a service to do it. Then you could do it on demand from an automation.

It is a bit of workaround but I built a service to automate firmware update of devices.

First you will need the the SSH & Web Terminal addon. This Guide was also very helpful in setting up the ability to use the shell command.

Next you need a shell command to run the update:

 esphome_update_device: ssh -i /config/.ssh/id_rsa [email protected] “sudo docker exec -t -w /config/esphome addon_5c53de3b_esphome sh -c ‘esphome run {{device}}.yaml --device OTA --no-logs’”

Now you can run the service:

service: shell_command.esphome_update_device
 device: smartplug1

Additionally, I added a service call to the device’s configuration so that is shows under the device integration.

  - platform: template
    name: “${friendly_name} Update”
    entity_category: config
    device_class: update
      - homeassistant.service:
        service: shell_command.esphome_update_ device
          device: ${device_name}