Show Device Group as Badge

For presence detection I use the Home Assistant iOS app and Locative. I previously had these grouped in the known_devices.yaml file but I recently split these out so that I had better visibility of which service was working better. Now for each person I have 2 device trackers so I put each set of 2 into a group (per person) and I use the group to trigger automations.

The trouble is that the group didn’t show as a badge in the front end (which is what I was used to). I’ve seen a few ways to sort this but I thought I’d share mine for reference. This is what I end up with:

image

The only difference to what I am used to is that the state shows where the name was and visa versa.

I did this using a template sensor:

sensor:
  - platform: template
    sensors:
      adam_badge:
        unit_of_measurement: Adam
		entity_id: group.adam
        friendly_name_template: >
          {% if is_state('group.adam', 'home') %}
            Home
          {% else %}
            Away
          {% endif %}
        value_template: >
          {% if is_state('group.adam', 'home') %}
            Home
          {% else %}
            Away
          {% endif %}
        entity_picture_template: http://www.gravatar.com/avatar/ab1e383c9a6fb394fe2afa5389c21657.jpg

As you can see I’ve had to set the friendly name of the sensor to either Home or Away (depending on the state of the group). This may seem a bit strange but the picture goes where the state normally does and this method allows the state to be displayed on the badge. It’s a shame you can’t use a template for the unit of measurement.

I hope this helps someone.

2 Likes