Compile ESPHome firmware updates on a Windows computer

UPDATE New, cleaner command from @Ellcon below. I’m not editing the whole post, but this TL;DR version is what you need: install python and esphome, update esphome as needed with
pip3 install esphome -U
then update all devices with
esphome -q update-all [directory containing yaml files]
For example, from inside the directory containing my yaml files, I use
esphome -q update-all .note the period is part of the command.

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.

Original wordy post here

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.

7 Likes

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.

Very useful guide, thank you !
I’m surprised not to see more comments here. I guess many people face the same problem and would be happy to compile on windows.
Did you update your process ?
There was lots or ESPHOME updates since january. Any changes? was the update notification problem solved?

To make the update process faster, we could automate the SCP. Using a script or maybe using directly a “samba share” integration. How to you proceed?

I’m mostly using the same process, although I’ve added the following to clean up the files I don’t need after the install: forfiles /M *.yaml /C "cmd /c esphome clean @file".

I recently upgraded to a Pi 5 and decided to install HASS on it instead of a custom install on top of DietPi like I had before. Since that upgrade, I can no longer see the .json files associated with the ESPHome devices. For now my choices are to ignore the “update available” message on the ESPHome tab or to go to each device, choose update, then stop the update.

The update notifications on the Settings tab remain accurate as they don’t seem to rely on the same json file as the ESPHome tab.

1 Like

I need to start doing this as I have to use the compile limiter to stop some of the esphome devices from crashing rp when compiling but it makes the process even slower.

Very nice find!

I found that in Linux update all is a valid option for command line but not in Windows. Also, some devices need to be totally powered off before firmware takes. Even on identical smart plugs.

A bit more testing so just to clarify my previous post. This works on both Linux and Windows command line. “–no-logs” doesn’t appear to be a valid option but “-q” does the same. Also has to be before “update-all”. The following will upgrade esphome and then compile/load all yaml’s in the specified folder.

pip3 install esphome --upgrade
esphome -q update-all c:\yamls\

Interesting, because --no-logs appears on the ESPHome Command Line Interface and just worked for me on Windows. The update-all option isn’t found on that page, but it worked on Windows and is a much cleaner solution. I’ll update the original post.

Also, the recent ESPHome updates required updating the ota configuration to add a platform (I used “esphome” as seen elsewhere on this forum) and moving the safe_mode configuration from under ota to its own config line. Everything is updated again with 2024.6.3

How do you select a com port for the esphome connection to the device? Following your comment, I can do compilation on windows 11 and then use esphome web to upload the code, if you can tell how to connect to com port from esphome in windows 11, that will be great!
Another question, can you also update the esphome version from windows also? I’m using raspberry pi 3b and it is impossible to update the version or compile, the compile issue is fixed by using this method no idea how to update the version.

My devices were already setup and functioning on the Pi’s esphome instance. That means they were properly setup for OTA updates. When I run the update, it executes over the air. There’s no com port selection required.

I do not believe there’s a way to update your RPi’'s software from Windows if you’re unable to update it directly on the box. However as I read elsewhere, if you can keep the devices up to date on your Windows machine, you might not need the ESPHome add-on in your HA installation anyway.

Sorry not to be clear. I wanted to say about the esphome version on the device. RAM has issue with updating esp device to latest esphome version and compiling and updating new yaml version. Esp devices have no issue otherwise and can connect and data from them is also displayed in HA.
If we can also update esp devices to latest esphome version via windows, that will be great.

Yes, you update the esphome version on your Windows machine with the command pip3 install esphome -U. Then you update the devices with:

esphome -q update-all [directory containing yaml files].

You really don’t need the add-on in HA to maintain existing devices. I find it easier to add new devices via the add-on and then manage them from Windows, but my understanding is that you can remove the ESPHome add-on if it’s not working for you.

1 Like

Thanks. Esphome removed armv7 support (raspberry Pi2) on version 2025.2.0. This is the solution to build the firmware updates for my esp-devices!

1 Like

I put something together to make compile & uploade more convenient.
Sorry for the typos, have fun: GitHub - TheSmartGerman/ESPHomeBuilderWinCompile: Compile your ESPHome Projects on a remote Windows PC

2 Likes

Can’t get the batch file to work:

Invalid number of parameters
The system cannot find the path specified.
Files given:
1 3d-printer-enclosure-extractor.yaml
INFO ESPHome 2025.2.2
INFO Reading configuration 3d-printer-enclosure-extractor.yaml...
ERROR Error while reading config: Invalid YAML syntax:

Error reading file common/.esp-config-default.yaml: [Errno 2] No such file or directory: 'common/.esp-config-default.yaml'

Well it seems this file is missing: common/.esp-config-default.yaml

I use xcopy. but it should copy also hidden and system files. you should find the file here: %TMP%\esphome\ + common/.esp-config-default.yaml before exit the batch script.

No it’s definitely there, is it because it has a dot at the beginning ? It looks greyed out ?

the dot at the beginning indicates a hidden file. The same reason it’s greyed out.

May you can delete the dot. should not make a difference for the compiler