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

25 lines
917 B
YAML
Raw 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)
| selectattr('attributes.in_progress', 'eq', false) |
| sort(attribute='attributes.installed_version')
| list }}
- condition:
- "{{ outdated_esp_items | count > 0 }}"
- service: update.install
target:
entity_id: "{{ outdated_esp_items[0].entity_id }}"
2023-05-05 15:25:23 +10:00
mode: single