From 72e8c5967834cc90883d111ccbeed111a819454a Mon Sep 17 00:00:00 2001 From: 31c0fe9c6dbd74bcdde92e1d2aaa03e1d272f75f Date: Fri, 5 May 2023 16:25:24 +1000 Subject: [PATCH] Home Assistant Git Exporter --- config/packages/meta.yaml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/config/packages/meta.yaml b/config/packages/meta.yaml index 65827b7..f5bdf0c 100644 --- a/config/packages/meta.yaml +++ b/config/packages/meta.yaml @@ -1,20 +1,24 @@ 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 alias: Auto-update ESP devices trigger: - platform: time_pattern hours: "3" 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: - - service: update.install - target: - entity_id: "{{ (states.update | selectattr('entity_id', 'match', 'update\.node\d+_firmware') - | selectattr('state', 'eq', 'on') | first).entity_id }}" + - 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 }}" mode: single