1
0
Fork 0
ha-config/config/packages/meta.yaml

27 lines
1004 B
YAML

automation:
# Based on https://community.home-assistant.io/t/auto-update-esphome-devices-via-automation/536573/15
- id: 0f9b330f-a026-49bc-9d1e-57d52f5ac625
alias: Auto-update ESP devices
trigger:
- platform: time_pattern
hours: "3"
minutes: "*"
action:
- variables:
outdated_esp_items: >-
{{ states.update
| selectattr('state', 'eq', 'on')
| selectattr('attributes.title', 'match', 'ESPHome')
| selectattr('attributes.auto_update', 'eq', false)
| selectattr('attributes.in_progress', 'eq', false)
| sort(attribute='attributes.installed_version')
| map(attribute='entity_id')
| list }}
next_to_update: "{{ outdated_esp_items | first }}"
- condition:
- "{{ outdated_esp_items | count > 0 }}"
- service: update.install
target:
entity_id: "{{ next_to_update }}"
mode: single