WTH, why do I need a complex template the get the number of persons home

Hello All,

it would be such a joy to have a number of persons at home that could be used to automate many things when it drops to 0 (if you have many people HA is tracking it is not trivial to do it now).

Thanks for listening!
B

maybe even vote for your own request,

1 Like

Voted!

I played with this a bit. Right now, for example, the zone zone.home always has the state zoning....
I think it would be more helpful if that actually contained the number of entities in that zone.

However, what would it show? The number of person entities in the zone? Or, the number of all entities in that zone? (as that would probably make it more useless for the home zone with all individual device tracker entities).

3 Likes

I would prefer the number of people.

4 Likes

Actually there is something which provides zone occupancy (so you can discover if there is any person in zone or none). I don’t remember right know the details because in my implementation I have exception for quests so has to do that other way. But I saw it for sure.

Regarding number of persons in a zone, it could be provided as attribute value. Wouldn’t it be enough?

I don’t use the person integration. I (and many other people) use my own custom integration which works much better. So I’d prefer it not require the use of person.

How about supplying a group and having it count the number of entities in that group that are in the zone? One might not care about certain entities, but only those in a particular group, so that would solve both problems.

3 Likes

So if you are using custom integration why not to count it by your integration? Or, lets say, by NodeRed or so… The latter has dedicated node for that.
But maybe I’m missing the point.

I do this:

group:
  anyone:
    name: 'Anyone'
    entities:
    - person.mike
    - person.kylee
    icon: mdi:home

  everyone:
    name: 'Everyone'
    entities:
    - person.mike
    - person.kylee
    all: true
    icon: mdi:home

They are groups but I basically just use them as binary_sensors. group.anyone's state becomes home if any one of its grouped people have state home otherwise it is not_home. group.everyone becomes home only if every one of its grouped people have state home otherwise it is not_home.

I don’t have an easy way to do an exact count without a template but I’ve never needed it personally, I’ve only ever needed to know those 4 states: whether or not anyone is home and whether or not everyone is home.

3 Likes

Hm I like that. Could be a setting on the zone. Either specify whether you want a count of device trackers or people in that zone. Or let people list the specific device_trackers and/or person entities they care to track so zones show a count of how many of those specific entities are inside.

The custom integration is for combining multiple device trackers and/or binary sensors per person. Adding this functionality would be outside its scope.

Of course a custom integration could be created do provide a count of some set of given entities, but I believe the point of this WTH topic is to suggest that maybe native HA should make it easy to do so.

1 Like

I actually like this! Thanks!

And that’s an easy and trivial out of the box solution :slight_smile: Using it since the beginning for many automations

You can assign multiple devices trackers to a person in HASS now. I do not recall when this was added, but I use it right now. :slight_smile:

I moved to this over from a bayesian sensor to person and haven’t had any issues, it even simplified my implementation.

Yes, thanks, I’m aware that is possible and has been for a while. And I guess it works ok for many people. But it doesn’t have all the features of my custom integration, nor do I believe it works as well as mine. If anyone is interested: https://github.com/pnbruckner/ha-composite-tracker

Yes, you can, but only device trackers, no binary sensor or anything else. If you want to include other entities than device trackers you either need to use @pnbruckner custom integration or create some kind of workaround to push the state from the binary sensor to a device teacker like e.g. the device _tracker.see service or an MQTT device tracker.

@Burningstone Correct! I failed to mention that, but showed an example in another thread.

@pnbruckner I’m a big proponent of what works for you! So I hope no one thinks my intention is that I’m being critical of custom components or anything I have posted is remotely viewed as a criticism.

For me I love the challenge of making something work with in the constraints of the system. There have been many times where I could have more easily written a custom component, push data to MQTT and have my own program process it, used node-red, or used appdaemon, etc… But my goal was always to make every attempt to solve the problem in HASS. This has lead me down some interesting paths, up to and including investigating the code to really understand what is happening and running debug sessions.

I like a good puzzle… :slight_smile: Call me crazy, but it is really one of the major things that drives me. :slight_smile:

No problem. Staying within what I think is the intended scope of this topic, I was simply explaining why I wouldn’t want any new feature that came out of this to depend solely upon the existing person integration.

Maybe I should start a new WTH topic asking why the person integration can’t do what my custom integration can. (I did offer it as a starting point to the person integration, since it existed well before that was started, but I don’t think it was looked at.)

1 Like

I also wonder why we don’t have a device_tracker template. :slight_smile:

1 Like

Do you have a WTH on this currently I can upvote? I forgot about this until you mentioned it. I also have gone looking for this and was surprised it didn’t exist

Done!