From c9f683378e9ce191af4e9f59ce1439472e7b7fbf Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Sat, 31 Aug 2024 12:23:54 +0200 Subject: [PATCH] Updated HACS management --- customizations/home_assistant.yaml | 3 -- packages/update/update_engine.yaml | 60 +++++++++++++++++++++--------- packages/update/update_types.yaml | 37 +++++++++++++++++- 3 files changed, 77 insertions(+), 23 deletions(-) diff --git a/customizations/home_assistant.yaml b/customizations/home_assistant.yaml index 591c8fe2..356680fe 100644 --- a/customizations/home_assistant.yaml +++ b/customizations/home_assistant.yaml @@ -14,9 +14,6 @@ script.homeassistant_reload_automations: script.homeassistant_clearlog: icon: mdi:file-document -script.homeassistant_upgrade: - icon: mdi:update - script.homeassistant_google_home_sync: icon: mdi:google-assistant diff --git a/packages/update/update_engine.yaml b/packages/update/update_engine.yaml index 0e4e110a..c3f2e3e4 100644 --- a/packages/update/update_engine.yaml +++ b/packages/update/update_engine.yaml @@ -17,37 +17,39 @@ automation: - alias: "Update: HACS Notification" id: "update_hacs_notification" - trigger: - - platform: numeric_state - entity_id: sensor.hacs - above: 0 + variables: + pending_update_list: > + {{ states.update + | selectattr('state','eq','on') + | selectattr('entity_id', 'in', states.group.hacs.attributes.entity_id) + | map(attribute='entity_id') + | list + }} + trigger: + - platform: state + entity_id: group.hacs + to: 'on' - platform: homeassistant event: start condition: - condition: numeric_state - entity_id: sensor.hacs - above: 0 + condition: state + entity_id: group.hacs + state: 'on' action: - - delay: '00:00:15' + - delay: '00:00:10' - service: script.notify_text data_template: title: "HACS - Aggiornamento" message: > - {% set update_number = states('sensor.hacs') %} - {% if is_state('sensor.hacs', '1') %} - E' disponibile un aggiornamento per i moduli HACS: - {% else %} - Sono disponibili {{ update_number }} aggiornamenti per i moduli HACS: - {% endif %} - {% for update in states.sensor.hacs.attributes['repositories'] %} - - {{ update['display_name'] }}: {{ update['available_version'] }} - {%- endfor %} + Sono disponibili {{pending_update_list | count }} aggiornamenti per i moduli HACS: + {% for entity_id in pending_update_list %} + -> {{ state_attr(entity_id, 'friendly_name')|replace(" - Aggiornamento", "") }}: {{ state_attr(entity_id, 'latest_version') }} + {%- endfor -%} notification_id: "update" enable_persistent: true - - service: input_boolean.turn_on entity_id: input_boolean.update_hacs @@ -72,3 +74,25 @@ automation: - service: persistent_notification.dismiss data_template: notification_id: "update" + +###################################################################### +# Update: Update all +# - update.install +###################################################################### + +# - alias: "Update: Aggiorna Tutto" +# id: "update_aggiorna_tutto" +# +# variables: +# pending_update_list: > +# {{ states.update +# | selectattr('state','eq','on') +# | selectattr('entity_id', 'in', states.group.hacs.attributes.entity_id) +# | map(attribute='entity_id') +# | list +# }} +# +# trigger: +# +# action: +# - service: update.install diff --git a/packages/update/update_types.yaml b/packages/update/update_types.yaml index bc118a8e..1a631f4b 100644 --- a/packages/update/update_types.yaml +++ b/packages/update/update_types.yaml @@ -38,9 +38,42 @@ group: ###################################################################### update: name: Aggiornamenti Disponibili - icon: mdi:package-up + icon: mdi:package-check entities: - #- input_boolean.update_homeassistant - input_boolean.update_hacs - input_boolean.update_shelly - input_boolean.update_bticino + + hacs: + name: HACS modules + icon: mdi:alpha-h-box + entities: + - update.auto_entities_update + - update.badge_card_update + - update.bar_card_update + - update.battery_state_card_entity_row_update + - update.browser_mod_update + - update.button_card_update + - update.card_mod_update + - update.clock_weather_card_update + - update.darkish_theme_update + - update.electrolux_care_integration_v2_not_official_update + - update.fold_entity_row_update + - update.hacs_update + - update.home_assistant_swipe_navigation_update + - update.horizon_card_update + - update.hui_element_update + - update.layout_card_update + - update.mercedesme_2020_update + - update.mini_graph_card_update + - update.monitor_docker_update + - update.mushroom_themes_update + - update.mushroom_update + - update.paper_buttons_row_update + - update.plotly_graph_card_update + - update.reeder_dark_theme_update + - update.shelly_em_firmware_update + - update.shutter_card_update + - update.tabbed_card_update + - update.vertical_stack_in_card_update + - update.zigbee2mqtt_networkmap_card_update -- 2.47.3