How to create a sensor to show how many wifi device trackers are "home"?

A zone entity shows in it’s state how many device trackers are currently in that zone.

I have several device tracker entities which track wifi clients through ping.
Let’s say, those trackers are
device_tracker.phone_stefan_wifi
device_tracker.phone_girlfriend_wifi
device_tracker.phone_child_wifi

I would like to create a sensor which shows how many of those wifi device trackers are “home”.
The reason is that I want to know who is actually inside the house vs. anywhere in teh home zone which I set to 50m radius. Plus at least my phone is set to turn off GPS via tasker when connected to the home wifi.

My first idea was to create a template sensor which just contains a bunch of IFs to increase the number state but I was wondering if there is a more elegant solution…

I think it is similar to the case discussed in this post: Sensor to count open windows - #24 by finity

It seems the one before last post is the solution. It uses groups.

1 Like

Indeed! Exactly what I was looking for and learned something new! Thanks!

1 Like