Compile ESPHome firmware updates on a Windows computer

TL;DR version: install python and esphome, update esphome as needed with pip3 install esphome -U then update all devices with esphome run --no-logs 1.yaml 2.yaml [list of each device in order]

I got tired of waiting upwards of 15 minutes for each ESPHome component to update, so I looked into how to speed the process up by moving the compiling tasks off my RPi4 and onto my Windows desktop. There is likely a cleaner way to accomplish this, and I will update if I’m told how to do it better.

First, I followed this guide to install python and esphome on my Windows computer.

Then I used WinSCP to login to my RPi and clone the homeassistant/esphome directory to my selected Windows directory, which was Documents\esphome.

I initially tested slowly to be sure I was doing it right. I opened a Windows command line and navigated to the Documents\esphome directory. There is a way to skip straight to updating, and I’ll get there. I ran these in order to be sure everything was installed properly:

esphome config basement.yaml # for example, that's one of my devices
esphome compile basement.yaml

The compile was finished in about 17 seconds compared to 15 minutes on the pi. After this I navigated to the Documents\esphome.esphome\build\basement.pioenvs\basement directory, copied the firmware.bin, and manually uploaded it to the basement device from the device’s webpage. Again I could have skipped some steps, but I wanted to be sure I saw this work correctly every step of the way.

For the next device, I ran the config/compile steps as above but uploaded OTA instead of manually uploading the firmware:

esphome upload bathroom.yaml

Like magic, the firmware was updated. I took the next baby step by running the whole process at once for the next firmware:

esphome run breakfast.yaml

This validates, compiles, uploads and then leaves the logs open. In my short experience, the log files didn’t close themselves, requiring me to hit Ctrl-C to exit. This seems to cause ESPHome to think an update is still available, even though the HA Settings detect it’s no longer available and the logs show the correct firmware is running.

To test my theory, I added the --no-logs command for the final yaml files. It’s not clearly documented, but this option is also essential if you want to update multiple files and don’t want to wait for the logs to stop displaying before compiling the next update. (I think the logs will eventually time out, but waiting lengthens the process.)

esphome run --no-logs halfbath.yaml littlelight.yaml livingroom.yaml tree.yaml

This updates each device in order. I thought adding the --no-logs command allowed ESPHome to detect the update was complete, but it turns out that wasn’t true for most of the devices.

It’s a little clunkier than clicking the “Update All” button that frequently fails, but it saves a ton of time. added a text file with the required commands to update so that I can easily copy and paste in the future. Yes I can write a batch file, but I still like to see the commands run one at a time.

Update: even the --no-logs option isn’t allowing ESPHome to detect the updates were completed. 2 of my 8 devices show up to date, even though all are running ESPHome version 2023.12.7 which is the most current as of now. Restarting ESPHome and HA had no effect. I’ll have to investigate further–any ideas?

Looks like the “Update Available” issue is what was reported here. I’ll either manually hit update and then stop as suggested or just ignore the ESP dashboard because HA knows when I actually need an update.