Pretty good answers so far. Iāll give you a slightly different take.
First, I use Life360 and an integration I created. (See Life360 and Life360 Device Tracker Platform.) Iāve been using Life360 for years, long before using HA, and I find that it works very well and suits our need for HA presence detection perfectly. Iāve also started looking at Google Maps Location Sharing for people who are often at our house but that donāt use Life360. So, basically, in my case, we only have one device_tracker per person and thatās all weāve needed. However, it does depend on a cloud service, so if youāre looking for something else, the suggestions above are excellent.
Next, as suggested, you should have a group that contains all the entities that ultimately track the individual people. E.g., if you just use a single device_tracker per person, then thereās already a group you can use that is automatically maintained - group.all_devices. Thatās what I use. Or, if you create other groups for each person then you should create a group that contains all of those (one per person.)
Next, as mentioned, this āall_devicesā or āall_peopleā group will be ānot_homeā when nobody is home, and āhomeā whenever at least one person is home. So itās pretty easy to create a trigger for the first person coming home. Itās just the group changing to āhomeā.
The āsomeone else just got homeā trigger, however, is a bit trickier. The easiest way to do this is to use a state to: 'home'
trigger and list out the individual device_trackerās or groupās (depending on what youāre using, one per person.) This will trigger whenever anyone gets home, regardless of how many people are already home. But you donāt want this to trigger for the first person. Thatās the harder part. You might think āIāll just use a condition that all_people is ānot_homeāā, but that probably wonāt work because as soon as the first person comes home, that group will also transition to āhomeā. Granted it might take a few milliseconds, but I wouldnāt count on it still being ānot_homeā when the automationās condition is evaluated.
So, what I do is I have a template sensor whose value is the number of people home. It just counts the number of entities in the all_devices group whose state is āhomeā. You can then use that in a numeric_state trigger with above: 1
. (And contrary to what the docs say, this will trigger whenever the count changes and itās value is above 1, not just when it ācrosses the thresholdā from 0 to 1.) The nice part is if you add people trackers, you only have to update the group (or it will update automatically if youāre using group.all_devices), but you donāt have to remember to update the automation triggers, too. But weāre not out of the woods yet! This is because in an automation triggered this way, we donāt have direct access to the entity that came home.
So, what Iād suggest is the automation runs a script (if it isnāt already running) that waits a few seconds, then announces the names of anyone who just came home during that wait period. I actually worked with someone else to implement this technique. The other advantage is if two or more people get home at about the same time there will only be one announcement with all their names.
Anyway, hopefully this gives you some other ideas. If you like any of this and would like to try it and need some help doing so, just let me know.