It sounds really simple, but I struggle with this for a while now. I want a automation that turns on the lights and starts playing radio when we come home.
I have created a automation that checks if someone is home. If there is someone home, the automation does not run. If there is no one home, the automation runs.
Now, the problem is. When my girlfriend and I come home together, the automation checks if someone is home. Since we arrive at the same time, the automation thinks someone is already home and therefor it will not run.
We use a group and have added each persons tracker entity OR each person entity (if trackers are already set) to that group, that way you can simply trigger off the group going from off to on.
Example Group:
house_occupied:
name: House Occupied
icon: mdi:home
entities:
- device_tracker.person_one
- device_tracker.person_two
# OR #
- person.person_1
- person.person_2
Zones in Home assistant have a state counting the number of people in that zone. So without knowing how many persons you have added to HA, you can simply test is zone.home is 0 or >0. This works for all zones you define on the map. I have two kids that go to the same school, if I wanted I could check if they are both there