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

27 lines
1004 B
YAML
Raw Permalink Normal View History

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