Show badge only when it exists?

So I’ve set up just a single badge in my view but I only want it to show up if that entity is available. In my case thats the updater.updater entity. Basically I don’t want anything showing up if I’ve got the latest version, but as soon as an update is available, I’d like for the badge to pop up so I’m aware there’s an update. Is this possible?

covered in the view documentation. Create an entity-filter object inside your badge section.

2 Likes

Thanks! Didn’t know that was possible. v0.103 should be out soon so will test if it works.

Code below if anyone else is interested:

  - badges:
      - entities:
        type: entity-filter
          - entity: binary_sensor.updater
            state_filter:
              - 'on'
1 Like

I didn’t either. I was curious when I saw your post. It looks like the new frontend dev is trying really hard to get all features people want into the frontend.

1 Like

Any luck with this ?
I might be rather full from Turkey but i can’t get this to work…

Yep, just use the below code:

  - badges:
      - entities:
        type: entity-filter
          - entity: binary_sensor.updater
            state_filter:
              - 'on'

This only works for versions that use the updater as a binary sensor though, older versions used the updater.updater entity, and you’d need a different state_filter for that I believe.

It’s also best to use the RAW Config editor and place it just under views but before cards like so:

views:
  - badges:
      - entities:
          - entity: binary_sensor.updater
            state_filter:
              - 'on'
        type: entity-filter
    cards:

How would I go about converting this view’s list of badges:

views:
  - title: Overview
    icon: mdi:home
    badges:
      - sensor.all_doors
      - sensor.all_lights
      - sensor.all_appliances
    cards:

to use entity-filter so that only the sensors that are not zero are displayed.

I know how to achieve that with an entity-filter card but don’t know how to apply that to badges.

    cards:
      - type: vertical-stack
        cards:
          - type: entity-filter
            state_filter:
              - operator: "!="
                value: "0"
            entities:
              - sensor.all_doors
              - sensor.all_lights
              - sensor.all_appliances

That’s easy.

  1. Eat less turkey :turkey:
  2. Read the docs referred to above. :open_book:
  3. Specify each badge as a separate entity filter. :name_badge:
  4. Develop the proper individual state filters. :man_technologist:

Done. :tada:

Currently, badges is a simple list of sensors. When I change that to contain the format shown in the documentation (for either entity-filter or state-label), the Visual Code extension reports numerous errors. The main error is that it is expects to see an array of strings.

Can someone provide a working example?


EDIT
Even the example shown above (by icaman004) fails to pass the extension’s check (and fails to work in the UI). I’m using version 0.103.2.

I discovered how to achieve my goal. This will display all_doors, all_lights, and all_appliances only if their value is non-zero.

views:
  - title: Overview
    icon: mdi:home
    badges:
      - type: entity-filter
        state_filter:
          - operator: "!="
            value: "0"
        entities:
          - sensor.all_doors
          - sensor.all_lights
          - sensor.all_appliances
      - sensor.indoor_temperature
      - sensor.indoor_humidity
      - sensor.outdoor_temperature
    cards:

Screenshot from 2019-12-26 09-58-16

However, version 1.4.5 of Home Assistant Config Helper (Visual Code extension) is not happy with the configuration’s syntax:

Screenshot from 2019-12-26 09-48-05

Here are the details for the first reported error:
Screenshot from 2019-12-26 09-52-46

This misled me to believe I had entered the information incorrectly. It appears the Config Helper extension needs to be updated; currently, this extension doesn’t fully support badges.


EDIT
I discovered there is a way to update the extension’s schema:

Currently, it expects badges to be an array of strings:
Screenshot from 2019-12-26 10-37-50

However, the array should also allow for badge objects that handle entity-filter and state-label.

3 Likes