Home » Blog » Automate ESPHome Device Updates in Home Assistant | The Ultimate Guide

Automate ESPHome Device Updates in Home Assistant | The Ultimate Guide

Hi! Here I am again, and this time with a super useful tip to automatically update your ESPHome devices as soon as a new ESPHome update is available. From now on, you won’t have to update your ESPHome devices manually anymore. With the automation and the script I’m going to show you in this video, you’ll update your ESPHome devices in no time!

⭐⭐⭐ NOTE: ⭐⭐⭐

This article accompanies a YouTube video. I wrote it for people who would rather read than watch a video. To keep doing this, I would like to ask you to also check out the video, leave a comment under the video, give the video a thumbs up, and subscribe to my YouTube channel. This means that the video is offered more often to new visitors so that they also stay informed of the latest Home Assistant tutorials.

Thank you for your support!


Click here to watch the video

If you use ESPHome, you probably recognize that you have to update all your ESPHome devices whenever a new ESPHome update is released. While it can be done relatively easily within the ESPHome interface itself, wouldn’t it be great if all your devices could update automatically as soon as the ESPHome update is installed? With the help of the automation and the script that I’m going to show you in this video tutorial, you can set it up yourself. I’ve chosen to use a script and an automation for this purpose, so you can also trigger the script via a button on your dashboard if you prefer not to update the devices completely automatically.

The script to update your ESPHome devices.

We start with the script that allows you to update all your ESPHome devices.

  1. Open Home Assistant.
  2. Go to Settings and click Automations and Scenes.
  3. Click the Scripts tab.
  4. Click Add script.
  5. Select Create New Script.
  6. Enter a name for your script, for instance: ESPHome: Update all ESPHome Devices.
  7. The first thing that we want to do is loop through all the ESPHome devices.
  8. For this, click on Add Building Block.
  9. Select Repeat.
  10. Select “For Each” in the Repeat Type dropdown box.
  11. Now we can create a list with all the items that we want to process. In our case, we are going to enter some template code here that retrieves all the ESPHome devices that need to be updated.
  12. Add the following code in the list field:
  13. This code returns all the esphome devices with the status update set to ‘on’.
  14. Next, we are going to add the action that updates the esphome device in the loop.
  15. Click Add Action.
  16. Scroll down and click Other Actions.
  17. Click Call Service.
  18. Select Update dot install in the service dropdown field.
  19. We will need to add some yaml now, so click on the three dots in the right upper corner of the call service section.
  20. Click Edit in YAML.
  21. Add the following code:
  22. What happens here, is that the esphome device that is selected in the loop will be updated.
  23. Now we’d like to wait until this device is updated before we go to the next device in the list.
  24. Click Add Building Block.
  25. Select the option Wait for a template in the dropdown box.
  26. Add the following code in the wait template field:
  27. Because of this code, the loop will pause until the selected ESPHome device is updated. After that, the next ESPHome device in the list will be processed.
  28. Click Save Script.
ClEAning up the YAML code

While creating this tutorial, I noticed that the code in YAML is in a different order than how we just entered it. This shouldn’t be a problem, but if you want to change it, go to the three dots in the upper right corner of the screen and click ‘Edit in YAML.’ Then, move the bottom part of the code up as I’m doing here and click ‘Save Script’ again.

Great! You have now created your script. You can start this script by creating a button on your dashboard or by creating an automation that automatically starts the script when ESPHome itself is updated.

I need your help!

You will be doing me a huge favor if you subscribe to my channel if you haven’t already. And, you help me a lot if you also give this video a thumbs up and leave a comment. This way, YouTube will present this video to new people and that will make the channel grow! In the description of the video, you will also find information about how you can sponsor me so that I can continue to make these tutorials for you.

Thank you!

The automation that automatically calls the script to perform the update.

If you want to automatically execute the script we just created, we need to create another automation that checks if there are ESPHome devices that need an update. By the way, this can all be done in a single automation without needing a script, but as I mentioned earlier in this tutorial, I chose to create a combination of a script and an automation so that you can also initiate the update via a button on your dashboard. If you want to know how to start an automation via a button on your dashboard, take a look at this video where I explain it step by step!

  1. Go to Home Assistant.
  2. Go to Automations & Scenes.
  3. Click Create Automation.
  4. Select Create New Automation.
  5. Click Add Trigger.
  6. Click Other triggers.
  7. Scroll down and click Template.
  8. Enter the following code in the Value template field:
  9. This code returns the number of esphome devices that need an update. We want to trigger the script that we’ve just created when the returned value is higher than zero.
  10. Click on “Add Action” in the “Then do” section.
  11. Scroll down and click “Other actions”.
  12. Scroll down and select “Script”.
  13. Select the script that we’ve just created. In our case it’s called ESPHome: Update all ESPHome devices.
  14. Click Save.
  15. Give your automation a meaningful name and click save again.


Your automation is now ready. From now on, all your ESPHome devices will be updated automatically whenever you update ESPHome. It might happen that an ESPHome device cannot be updated because it uses code that is not compatible with the new version of ESPHome. In that case, the updating process will stop at that device. You will need to wait until the developer of the code for that ESPHome device makes the code compatible with the latest version of ESPHome. Alternatively, you can modify the code yourself if you know how to do it.

If you find it too much work to type the code from the screen, you can download the blueprint I have created for this purpose for a small fee. It saves you a lot of effort and frustration, and you help me keep this channel alive. You’ll find the link to the blueprint that automatically updates the ESPHome devices in the description of this video.

Thanks for watching, and I hope this tutorial has made your Smart Home life a bit easier. Do me a favor, give this video a thumbs up, and subscribe to my channel. It would be great if you leave a comment down below as well. This ensures that YouTube will show my videos to more people. If my videos save you time and you want to ensure that this channel continues to exist, consider sponsoring me, just like these fantastic people do. Thanks to all of you, I can keep creating tutorials for the community. Thank you.

See you soon in my next video!

Bye Bye!

#ESPHome #EffortlessUpdates #ComprehensiveGuide #HomeAutomation #SmartHome #DIY #IoT #FirmwareUpdates #UpdateGuide #ESP8266 #ESP32 #Automation #OpenSource #InternetOfThings #IoTProjects #DIYProjects #TechGuide #SmartDevices #HomeUpgrade #SmartLiving

, ,

Back to all articles