Automating System Updates with ESPHome

I recently came across a video discussing how to automate updates for ESPHome devices, which got me thinking about how to implement a similar system for my Home Assistant setup. The idea is to have a daily check for pending updates and receive a notification if any are available. This would save me from manually checking for updates, which I sometimes forget to do.

I decided to give it a try and set up an automation using ESPHome. The automation was supposed to trigger every day at a specific time, check for updates, and send a notification if any were found. Here’s the setup I used:

yaml
alias: Notify - updates available
trigger:

  • platform: time
    at: “04:55:00”
    condition:
  • condition: template
    value_template: >-
    {{ states.update | selectattr(‘state’,‘eq’,‘on’) | map(attribute=‘entity_id’)|list}}
    action:
  • service: notify.mobile_app_grant_nord2
    data:
    message: >-
    Updates available - {{ states.update | selectattr(‘state’,‘eq’,‘on’) | map(attribute=‘entity_id’)|list}}
    title: Home Assistant
    mode: single

Initially, it worked when I tested it with four pending updates. However, when I checked the next day, the automation hadn’t run, and the condition wasn’t passing. I suspect there might be an issue with the template or the way the states are being evaluated.

I’m curious if anyone else has successfully implemented a similar system or encountered similar issues. Any insights or suggestions would be greatly appreciated! Let’s discuss how we can refine this automation to ensure it runs smoothly every day.