Script to Update all updateable devices (shelly/wled) at once

Just want to add my working solution in 2025 for upgrading all Shelly products in my home realm which the Shelly integration identifies as upgradeable.

Create script and edit in .yaml. Copy/paste following:

sequence:
  - action: update.install
    target:
      entity_id: >
        {%- set find_integration = 'shelly' %}  
        {%- set entities = states | map(attribute='entity_id') | list %} 
        {%- set ns = namespace(entities = []) %} 
        {%- for entity_id in entities %}
          {%- set ids = device_attr(entity_id, 'identifiers') %}
            {%- if ids %} 
            {%- set ids = ids | list | first %}
              {%- if ids and ids | length == 2 and ids[0] == find_integration and 'update' in entity_id%}
              {%- set ns.entities = ns.entities + [ entity_id ] %}
            {%- endif %}
          {%- endif %}
        {%- endfor %} 
        {{ ns.entities }}
    data: {}
mode: single
icon: mdi:shield
alias: Update_all_Shelly
description: "Update Firmware of all Shelly"

In case a device has no FW update available, then an error occurs (actually it´s a Warning, since the script continues anyway). In my case the output trace is as follows:

Executed: March 26, 2025 at 11:01:25 PM
Error: No update available for update.eg_kuche_rechts_r_firmware
Result:
params:
  domain: update
  service: install
  service_data: {}
  target:
    entity_id:
      - update.ke_treppe_l_firmware
 ---------[... I cutted here the list of devices, since too long ...] -----------
      - update.og_flur_l_firmware
running_script: false

You need to run manually the script. If you wish, you could add it in your favorite dashboard with a button. For me it’s an overkill and I’m happy to run manually if I need it to.

Probably one could implement much simpler ways… However it works on my HA 2025.3.4.

Note: I merged the infos in this post and the ones here: https://community.home-assistant.io/t/how-to-enumerate-entities-belonging-to-an-integration/343748/6

Have fun!