Using images in badges based on state filter

Hi all - I am trying to display badges to show whether my users are home or away. I wanted to use badges not cards as the main purpose of this dashboard is to be displayed on a phone.

I wanted to show the user’s picture if the are home - or the same picture ‘greyed out’ if they are away. If I just put the user’s badge in like

- badges:
  - entity: person.matt

then I get the photo but it doesn’t change - only the words ‘home’ and ‘away’ appear on top of the badge.

If I create a state filter like this:

    badges:
      - type: entity-filter
        entities:
        - entity: person.matt
          name: Matt
          image: local/matt.png
          #icon: mdi:home-account
        state_filter:
        - "home"
      - type: entity-filter
        entities:
        - entity: person.matt
          name: Matt
          image: local/matt-away.png
          #icon: mdi:home-edit-outline
        state_filter:
        - "away"

Then my badges are just an an empty white circle. The image URL’s are definitely correct because if I use those same URL’s in a card they work fine. Furthermore - if I comment out the ‘image’ line in the code above and uncomment the ‘icon’ line then instead of an image or the blank white circle I get a badge with an icon which changes correctly with my home/away state.

Does anyone know if/how I can make the photo inside the badge change dependent on the user’s home/away state? I’ve googled and tried various suggestions about customize.yaml etc but nothing seems to work.

The url needs a slash:


      - type: entity-filter
        entities:
        - entity: person.matt
          name: Matt
          image: /local/matt-away.png
          #icon: mdi:home-edit-outline
        state_filter:
        - "away"

1 Like

Thank you very much indeed - very grateful :slight_smile:

You’re welcome! :slightly_smiling_face: