Hi
I have some logic in some of my lighting automations that triggers lighting switch off faster when there’s only 1 person present. Which works great, but if there’s only 1 person here + we have a guest staying then there will be people showering in the dark.
So I was trying to modify my template sensor to also track when a guest is present and count them into my “someone is here” sensor.
Our guest mode is a boolean triggered either manually or by a calendar event
Resident presence is detected by the normal device_tracker.
However it makes more sense to have new tracked devices/people be included automatically rather than having to manually update the sensor every time a new one is added, but I’m stuck on how to write this in jinja.
The normal approach to seeing how many people are present in a zone is currently to use the state of the zone, which counts the people there by itself. Counting people makes more sense to me than counting device trackers, as one person may have more (I do), and not all device trackers may represent people (car, …). So if you introduce guests as a person into HA, wouldn’t the zone state already do what you want?
Yes, thank you. Both worked.
I tried all kinds of stuff similar to your #1 , but I didn’t try just adding a +
@Edwin_D Yes, counting per person/zone is probably better logic as long as it can still monitor each person present at home, but thanks to @tom_l I should be able to whip something up
FWIW, the abs filter can convert boolean values into integers (true = 1 and false = 0). We can leverage that feature to convert an input_boolean’s state into an integer value.