1
0
Fork 0

Home Assistant Git Exporter

main
31c0fe9c6dbd74bcdde92e1d2aaa03e1d272f75f 2023-05-05 16:25:24 +10:00
parent ddcbf67e45
commit 72e8c59678
1 changed files with 15 additions and 11 deletions

View File

@ -1,20 +1,24 @@
automation: automation:
# https://community.home-assistant.io/t/auto-update-esphome-devices-via-automation/536573/15 # Based on https://community.home-assistant.io/t/auto-update-esphome-devices-via-automation/536573/15
- id: 0f9b330f-a026-49bc-9d1e-57d52f5ac625 - id: 0f9b330f-a026-49bc-9d1e-57d52f5ac625
alias: Auto-update ESP devices alias: Auto-update ESP devices
trigger: trigger:
- platform: time_pattern - platform: time_pattern
hours: "3" hours: "3"
minutes: "*" minutes: "*"
condition:
- "{{ states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware')
| selectattr('state', 'eq', 'on') | list | count > 0 }}"
- "{{ states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware')
| selectattr('attributes.in_progress') | list | count == 0 }}"
action: action:
- service: update.install - variables:
target: outdated_esp_items: >-
entity_id: "{{ (states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware') {{ states.update
| selectattr('state', 'eq', 'on') | first).entity_id }}" | 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 }}"
mode: single mode: single