✅ Update Card - showing available updates categorized

Hi to everyone,

in a theme I encountered I found an update card and I was wondering how it would work and I was interested in 1. having the card automatically filtering their original category and 2. the card should automatically find update entities, so if you remove or add addons, they’ll show up or don’t. So this is my approach. There is an issue though with a kind of border being around the mushroom update card that I wasn’t able to get rid of. So here’s my code for you and further development in case you’re interested in having such a card in the first place.

type: vertical-stack
title: ''
cards:
  - type: custom:vertical-stack-in-card
    cards:
      - type: custom:mushroom-title-card
        title: Updates
      - type: conditional
        conditions:
          - condition: state
            entity: sensor.updates_available
            state: '3'
        card:
          type: vertical-stack
          cards:
            - type: custom:mushroom-title-card
              title: ' Home Assistant Server'
              subtitle: ''
            - type: custom:auto-entities
              card:
                type: entities
                state_color: false
              filter:
                include:
                  - domain: update
                    integration: hassio
                    state: 'on'
                    entity_id: '*sys'
                    options:
                      type: custom:mushroom-update-card
                      show_buttons_control: true
                      icon_type: entity-picture
                      layout: horizontal
                exclude: []
              sort:
                method: entity_id
              show_empty: false
      - type: conditional
        conditions:
          - condition: state
            entity: sensor.updates_available
            state: '3'
        card:
          type: vertical-stack
          cards:
            - type: custom:mushroom-title-card
              title: ' Addons'
              subtitle: ''
            - type: custom:auto-entities
              card:
                type: entities
                state_color: false
                show_header_toggle: false
              filter:
                include:
                  - domain: update
                    integration: hassio
                    state: 'on'
                    options:
                      type: custom:mushroom-update-card
                      show_buttons_control: true
                      icon_type: entity-picture
                      layout: horizontal
                exclude:
                  - entity_id: '*sys'
              sort:
                method: entity_id
              show_empty: false
      - type: conditional
        conditions:
          - condition: state
            entity: sensor.updates_available
            state: '3'
        card:
          type: vertical-stack
          cards:
            - type: custom:mushroom-title-card
              title: ' HACS'
              subtitle: ''
            - type: custom:auto-entities
              card:
                type: entities
                state_color: false
              filter:
                include:
                  - domain: update
                    integration: hacs
                    state: 'on'
                    options:
                      type: custom:mushroom-update-card
                      show_buttons_control: true
                      icon_type: entity-picture
                      layout: horizontal
                exclude:
                  - entity_id: '*sys'
              sort:
                method: entity_id
              show_empty: false
      - type: conditional
        conditions:
          - condition: numeric_state
            entity: sensor.updates_available
            below: 1
        card:
          type: custom:mushroom-template-card
          icon: mdi:check
          icon_color: green
          primary: No Updates available

1 Like

Is sensor.updates_available a template sensor that counts all the update.*_updates?

yes, sorry, could’ve mentioned that :slight_smile:

1 Like

Why does sensor.updates_available need to be 3 for some of the conditional cards?

I played around with this a lot, can’t tell you exactly how that works, because I wouldn’t know it, but I wanted to show the category only, if an update for that category was available, if not it shouldn’t show and if none at all are available, then the “no updates available” card will show. this was my approach, I’m sure there are better constructed ways but I don’t know anything about coding and the possibilities, I read, try, apply and experiment and hope it works I the end. So if anyone knows how to fix that gap/border I mentioned I’d be happy :see_no_evil:

I think I know this but waiting for a genuine update before I confirm and will then reply here :+1:

1 Like

OK,

SO I have 2 copies of the code: yours & mine. I have 2 HACS updates. They both look like this"

Mine:
Screenshot 2024-08-27 at 08.37.32

Yours:
Screenshot 2024-08-27 at 08.38.33

Ignore mine having* MQTT and no others etc (I’m running in docker so no Supervisor). I think I have removed all the extra* lines in mine - is that what you are looking for?

[edited for typos*]

1 Like

Yes, I think you solved it! Thanks a lot! Btw: Does your update card take some time to process the updates, because mine does takes its time. What I mean is it’s not instantly appearing but takes a few seconds… :slight_smile:

yes, it took a short time - not long but noticeable.

OK, copy/paste the below.

The differences are:

  • All the custom:auto-entities cards are now under a single conditional-card. You had each one in its own and I think that was causing the extra lines (multiple cards causing multiple lines).
  • I am only using numeric-state in the condition, I think it’s tidier.

Let me know if this works for you (or not).

type: vertical-stack
cards:
  - type: custom:vertical-stack-in-card
    cards:
      - type: custom:mushroom-title-card
        title: Updates
      - type: conditional
        conditions:
          - condition: numeric_state
            entity: sensor.updates_available
            above: 0
        card:
          type: vertical-stack
          cards:
            
            # HAS
            - type: custom:mushroom-title-card
              title: 'Home Assistant Server'
            - type: custom:auto-entities
              card:
                type: entities
                state_color: false
              filter:
                include:
                  - domain: update
                    integration: hassio
                    state: 'on'
                    entity_id: '*sys'
                    options:
                      type: custom:mushroom-update-card
                      show_buttons_control: true
                      icon_type: entity-picture
                      layout: horizontal
                exclude: []
              sort:
                method: entity_id
              show_empty: false
            
            # Addons
            - type: custom:mushroom-title-card
              title: 'Addons'
            - type: custom:auto-entities
              card:
                type: entities
                state_color: false
                show_header_toggle: false
              filter:
                include:
                  - domain: update
                    integration: hassio
                    state: 'on'
                    options:
                      type: custom:mushroom-update-card
                      show_buttons_control: true
                      icon_type: entity-picture
                      layout: horizontal
                exclude:
                  - entity_id: '*sys'
              sort:
                method: entity_id
              show_empty: false
            
            # HACS
            - type: custom:mushroom-title-card
              title: 'HACS'
            - type: custom:auto-entities
              card:
                type: entities
                state_color: false
              filter:
                include:
                  - domain: update
                    integration: hacs
                    state: 'on'
                    options:
                      type: custom:mushroom-update-card
                      show_buttons_control: true
                      icon_type: entity-picture
                      layout: horizontal
                exclude:
                  - entity_id: '*sys'
              sort:
                method: entity_id
              show_empty: false
      
      # no updates
      - type: conditional
        conditions:
          - condition: numeric_state
            entity: sensor.updates_available
            below: 1
        card:
          type: custom:mushroom-template-card
          icon: mdi:check
          icon_color: green
          primary: No Updates available

Thanks for your Code! It works better than mine, also there was an issue with my theme. I am wondering though, if we could hide the categories that don’t have any updates to show, in my case here it’s addons that doesn’t have any currently and secondly is there a way to hide the word “update” in the show name of auto entities, do you know that? :see_no_evil:

Yes, I’ve already done that to mine, but was trying to keep yours as close to as you had it. I’ll post my changes tomorrow.

1 Like

Pardon my newbie question but how exactly do you configure the sensor.upstates_available?

So I just created a simple template sensor. First I added this line to my configuration.yaml so all the template sensors are in one place: template: !include template.yaml
then if you don’t already have the template.yaml file create it and paste the following code. Safe the file. Check configuration in developer tools. Restart Home Assistant. Then this update entity will appear and you can use it.

UPDATES

  - name: "Updates Available"
    state: >
      {{ states | selectattr('entity_id', 'match', 'update\..*') 
                 | selectattr('state', 'eq', 'on') 
                 | list 
                 | count }}
    icon: mdi:update
1 Like

hey :slight_smile: do you have time for posting the code? :slight_smile: thank you

@specialist0
Many many thanks

of course. Sorry, I got caught up in other things and it slipped my mind.

This is what I did:

I created a specific sensor for each part (mine are different to yours, but you get the drift).

template:
  - binary_sensor:
      - name: "MQTT update available"
        state: >
          {{ expand(integration_entities('mqtt'))
            | selectattr('domain','equalto','update')
            | selectattr('state','equalto','on')
            | list
            | count
          }}
      - name: "HACS update available"
        state: >
          {{ expand(integration_entities('hacs'))
            | selectattr('domain','equalto','update')
            | selectattr('state','equalto','on')
            | list
            | count
          }}

And then I modified the dash view as follows:

- type: vertical-stack
  cards:
    # none
    - type: conditional
      conditions:
        - condition: state
          entity: sensor.count_of_updates
          state: 0
      card:
        type: custom:mushroom-template-card
        icon: mdi:check
        icon_color: green
        primary: No Updates available

    # HACS
    - type: conditional
      conditions:
        - condition: state
          entity: binary_sensor.hacs_update_available
          state: "on"
      card:
        type: vertical-stack
        cards:
          - type: custom:mushroom-title-card
            title: 'HACS'
          - type: custom:auto-entities
            card:
              type: entities
              state_color: false
            filter:
              include:
                - domain: update
                  integration: hacs
                  state: 'on'
                  options:
                    type: custom:mushroom-update-card
                    show_buttons_control: true
                    icon_type: entity-picture
                    layout: horizontal
            sort:
              method: entity_id
            show_empty: false

    # MQTT
    - type: conditional
      conditions:
        - condition: state
          entity: binary_sensor.mqtt_update_available
          state: "on"
      card:
        type: vertical-stack
        cards:
          - type: custom:mushroom-title-card
            title: 'MQTT'
          - type: custom:auto-entities
            card:
              type: entities
              state_color: false
            filter:
              include:
                - domain: update
                  integration: mqtt
                  state: 'on'
                  options:
                    type: custom:mushroom-update-card
                    show_buttons_control: true
                    icon_type: entity-picture
                    layout: horizontal
            sort:
              method: entity_id
            show_empty: false

Now, you will also want a binary_sensor for HAS and addons, so yours should look like this:

template: 
  - binary_sensor:
      - name: "Addon update available"
        state: >
          {{ expand(integration_entities('hassio'))
            | selectattr('domain','equalto','update')
            | rejectattr('entity_id','search','sys')
            | selectattr('state','equalto','on')
            | list
            | count
          }}
       - name: "HAS update available"
        state: >
          {{ expand(integration_entities('hassio'))
            | selectattr('domain','equalto','update')
            | selectattr('entity_id','search','sys')
            | selectattr('state','equalto','on')
            | list
            | count
          }} 
      - name: "HACS update available"
        state: >
          {{ expand(integration_entities('hacs'))
            | selectattr('domain','equalto','update')
            | selectattr('state','equalto','on')
            | list
            | count
          }}

and then you’d use the same type: conditional for them in your dash view …but I can’t be 100% sure I got your binary_sensors right because I am not running HAS and can’t test it.

Try it and come back here with any questions :+1:

Just seen this and I can see that @specialist0 has already answered.

this works! thank you. aside from the delay of checking the sensor status it’s become a useful card

1 Like