Sensor to count guests connected to Unifi guest network

What I am trying to do is create a sensor that shows the total amount of people connected to my Unifi guest network using the is_guest state

I have created the sensor, but it always shows a value of 0, even though I currently have 1 device connected to the network

  - platform: template
    sensors:
      guest_count:
        friendly_name: Guest Count
        value_template: >-
          {{ states.device_tracker | selectattr('is_guest', 'eq', 'true') | list | count }}

Any idea what i’ve done wrong?

1 Like

Try adding attributes to is_guest:

{{ states.device_tracker | selectattr('attributes.is_guest', 'eq', 'true') | list | count }}

Thanks for the suggestion. Unfortunately, I get the same result when I add this

Resolved!

{{ states.device_tracker | selectattr('attributes.is_guest', 'eq', true) | list | count }}

Needed to remove the quotes around true

6 Likes