[UniFi] Check if new firmware is available for UniFi devices

Hi all,

I’d like to create a card on my dashboard to quickly see if one of my devices need to be upgraded.
It does work well for HA and my Pi-Hole, but I’d like to do similar thing to check if one of my UniFi needs a firmware upgrade (I have an USG, 4 switches and 2 APs).

unifi0

I can see the current firmware of my devices in the UniFi integration as illustrated below.

unifi1

But, I cannot see it in the sensor state.

unifi2

Do you know how can I collect the value ?

But then, even if I’m able to get the current firmware value, I don’t know to what can I compare it in order to know if a new version is available… (like I did for HA by comparing sensor.installed_version and sensor.latest_available_version). Any advice is more than welcome :slight_smile: Thanks

Since the latest firmware is 4.3.22.11330 and not 4.3.21.11325 and one of your attributes states that “upgradable” is “true” you can use that attribute to fire an action that there is an update available.

How did I not see this attribute :frowning: Thanks!
The 2 UniFi devices that actually have a firmware update available are the 2 where I see this attribute “upgradable: true”.
The other UniFi devices that don’t have an update available don’t have this attribute at all.

unifi3

Thanks again @heartkingz!

2 Likes

Have to admit that I never knew that the “upgradable” attribute was there, until I saw it in this post, lol!
I think we helped each other out, so thank you too!

1 Like

Ok so I created something very basic (in fact, like all that I’ve done so far in my HA dashboard… :smiley: ) to see a green color on the custom button card of each of my UniFi device if an upgrade is available (using the attribute).

unifi4

      - name: Main Switch
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:server-network'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_main_switch'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]

Don’t know if it is the best way to do that, but it works :slight_smile:

1 Like

Would you mind posting your full code for that card? I am interested in doing a similar thing for my Unifi network.

Regards
James

Sure, here it is. Again, I’m still discovering and learning about HA so my configuration is very basic. Sorry about that.
I use mainly “custom-button” on my dashboard.

cards:
  - color: 'rgb(82, 147, 226)'
    color_type: label-card
    name: UNIFI NETWORK UPGRADE AVAILABLE
    styles:
      card:
        - height: 40px
      name:
        - justify-self: start
        - padding-left: 25px
    type: 'custom:button-card'
  - cards:
      - name: USG
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:security-network'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_usg'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
      - name: Main Switch
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:server-network'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_main_switch'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
      - name: PoE Switch
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:server-network'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_poe_switch'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
      - name: CloudKey
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:shield-key'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_cloudkey_g2'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
    type: horizontal-stack
  - cards:
      - name: Mini Bas
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:server-network'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_flex_mini_bas'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
      - name: Mini Haut
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:server-network'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_flex_mini_haut'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
      - name: AP Bas
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:access-point'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_ap_bas'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
      - name: AP Haut
        type: 'custom:button-card'
        size: 35%
        icon: 'mdi:access-point'
        styles:
          card:
            - background-color: |
                [[[ 
                  if (states['device_tracker.unifi_ap_haut'].attributes.upgradable === 'true')
                    return 'green';
                  else
                    return 'none';
                ]]]
        tap_action:
          action: none
    type: horizontal-stack
type: vertical-stack

Many thanks, I just need to wait for an update to be released to test it!

Regards
James