Show Shelly devices which need update and display button

Hi,
with the new button entity it’s quite easy to show all shelly devices which need an update, and display the button to click.

Prerequisites:

  • Installed auto-entities
  • Naming of the button entity and binary_sensor entity which is on whenever a firmware update is available is similar (e.g. button.devicename_ota_updatebinary_sensor.devicename_firmware_update)
  • Native Shelly integration (not tested with Shelly4Hass)

Code:

card:
  show_header_toggle: false
  title: Shelly need update
  type: entities
filter:
  template: |-
    {%- for state in states.binary_sensor -%}
      {%- if state.entity_id | regex_match("binary_sensor.*firmware", ignorecase=False) -%}    
        {%- if is_state(state.entity_id,"on") -%}
          {{
            {
              'entity': state.entity_id|replace("binary_sensor","button")|replace("firmware","ota"),
              'name': "Update "~state.attributes.friendly_name.split('Firmware')[0]
            }
          }},
       {%- endif -%}
      {%- endif -%}
    {%- endfor -%}
type: custom:auto-entities

(Credits also to @Ildar_Gabdullin who helped me with this code snippet in a different problem. I adjusted it to this purpose.)

It just replaces the binary_sensor prefix with button, and firmware with ota.
It’s not the best code, but maybe somebody finds it useful :slight_smile:

Cheers Ben

4 Likes

With a quick rename of entity_ids this catches WLED updates too.

Any chance you could share you code that captures WLED too?

I no longer have binary_sensor entities for firmware updates. They have all been transitioned to update entities.

Here is my dashboard card that shows update buttons for shelly and wled:

card:
  show_header_toggle: false
  title: Shelly need update
  type: entities
filter:
  template: |-
    {%- for state in states.update -%}
      {%- if state.entity_id | regex_match("update\..*firmware.*", ignorecase=False) -%}    
        {%- if is_state(state.entity_id,"on") -%}
          {{
            {
              'entity': state.entity_id|replace("binary_sensor","button"),
              'name': state.attributes.friendly_name.split('Firmware')[0]
            }
          }},
       {%- endif -%}
      {%- endif -%}
    {%- endfor -%}
type: custom:auto-entities
1 Like

Thanks a lot @Ramblurr it works perfectly !
I now have a list of my Shelly devices that need to be updated :+1:
I’m now just wondering if it’s possible to also add a single button to launch every update on each Shelly automatically, based on this list?

Here’s how you do it if you want to check for firmware updates on Gen2 devices upwards:

"curl -s --digest -u admin:<yourPassword> 'http://<IPaddress>/rpc/Shelly.CheckForUpdate'"

For further commands check this source:
Shelly | Shelly Technical Documentation