Device tracking... how to base presence detection state on 2/3 of devices?

I’m using multiple trackers right now… iOS, Owntracks, nMap. I find they they all don’t always work, but usually 2 of 3 report correctly. How can I base my location state (home/not_home) on 2 of the 3? So for example… if iOS and nMap say I am home, but Owntracks is stuck in a location outside of my zone and hasn’t updated, my overall location state will be home.

I think I could set it up with a set of conditions such as:

if 1 and 2 are ‘home’
or
if 1 and 3 are ‘home’
or
if 2 and 3 are ‘home’

and so on…

but maybe there is an easier way?

Thanks!

Don’t iOS and Owntracks do the same thing (gps location)? I would drop one of them, as having 2 gps trackers shouldn’t increase accuracy or precision since they are both reading the same GPS and all you really are doing is doubling the number of reports.

Also, if you put multiple device_tracker entities in a group, then the group will have a state of home if any of the device_tracker entities has a state of home. So, I use DDWRT and gpsLogger and they get tracked as two separate entities, but I put them in a group it changes from home to not_home automatically.

Granted, for my own setup, I rely on the gpsLogger for all individual person related automations, and I use the group.all_devices for house occupied automations.

I’m not sure how having only one gps tracker would increase accuracy and precision?

I know you can put them all in a group, but I don’t want the situation where it only takes one tracker to change for the group to change. I’ve had my garage door open in the middle of the night because one tracker switched to ‘away’ for whatever reason. If it were set up where it takes two of the three trackers to to switch states then, this problem could be avoided for the most part.

I never said that only one gps tracker would increase accuracy or precision. All I said is having 2 services report from the same sensor doesn’t provide any meaningful benefit. I mean, the only thing it would do is provide a backup in case iCloud goes down, which is rare. It also will take more data (if that matters) and possibly drain more battery (waking up the device twice as often to get a gps location)

If one device in a group changes to not_home, the group state will remain home. So, your example couldn’t have been running based off of a group with at least 1 entity set as home. A group is the simpler answer you are looking for, as false positives that you are home pretty much don’t exist, while false negatives are more common. Since all of the sensors say you have to be not_home for the group to change, the group achieves what you asked about (home vs not_home status).

I mean, if you want you can create a template sensor that checks for a 2 out of 3 condition exactly like you suggested, but 2 of them are reading the same sensor, so you are weighting the decision in favor of a single gps reading and you really only have 2 unique sensors. A GPS drift would cause 2 of the entities to report not_home and then the state would toggle while nmap says you are home and is correct.

EDIT: and if it isn’t clear, I’m talking about having each device_tracker component report a unique entity even though they are tracking the same thing. Otherwise if there is only one entity then whoever reports last gets the final say. So, I have device_tracker.myPhone, and device_tracker.myPhoneGps and I group them later.

I’ve been running iOS and Owntracks for awhile and I’ve found that they are both unreliable to an extent, but not identical. Sometimes one is reporting where I a while the other is stuck somewhere 2 miles from where I currently am. So, I dunno how they are different, but they are. I’ve only just set up icloud tracking, so I’m not sure how well that one works. Do you use it?

I think I’ll just have to do some experimenting with what you are saying to see how it goes. Thanks for your thoughts.

I use “or” for home on single tracker but “and” for away on 2 of 3.

For home:

a or b or c

For away:

a and b OR b and c OR a and c

If I had to do it again I’d use the Bayesean sensor and put them all in and let it sort it out.

Yeah I’ve seen some stuff about the bayesean sensor. You say you would let it sort it out… does it determine the statistical stuff on it’s own? I wasn under the impression you had to set this manually, and I figured I could do this in a simpler way.

This is the issue I’m talking about. So currently Owntracks is reporting correctly… but iOS has been stuck several blocks away all morning.
47 AM

I’d put all 3 in and say that to be “home” you need 0.9 probability overall, and weight each sensor as 0.5 probability for being correct. That way if 2 of the 3 are home sensor will indicate home.

If 2 of 3 are away it will state not home.

Or if your accuracy is better detecting away you can reverse that logic.

Also you can use device_class inside the bayesian so you can set it as a presence detector for the icons and gun labelling.

ok, yeah … the other issue was that I didn’t really understand the concept of doing the statistics. Not something I ever learned. I kinda understand what you are saying. Basically for each tracker reporting home it adds 0.5… so that if there are two, you get a total 1.0, when you are asking for only 0.9. So that fulfills the requirement, correct?