Person - Leaving Home Scenario (Away)

So I have an interesting use case that the person logic seems to not work for. My kids are required to have their phones powered off at school. So when they leave for school, they power them off. I thought using a person with two devices trackers would figure this out a little better.

Each kid has a device_tracker GPS from Home Assistant Companion IOS app which is GPS based and then they also have a stationary tracker with Unifi (wifi).

When they leave the wifi area, the stationary tracker marks them away but according to the logic of the person state, when someone “leaves” home, it moves from stationary tracker to GPS tracker which then marks them home. I would think it would mark them away and then wait for next GPS update. In my case the GPS update will never occur because the phone is powered off.

Anyone have ideas or thoughts if the logic could be enhanced to account for a stale GPS scenario? Essentially it seems like GPS is king, all the time. I might have to just go back to wifi only tracking for them and not use the person object for automations.

I would think when the WiFi tracker is away, the person component should then see where they are based on the gps tracker. In your case they are home because they turned them off whilst they were home.

If that’s what they’re going to do 5/7ths of the time, what’s the point in them having a GPS tracker in their ‘person’?

Remove the gps tracker from their person, or use only the WiFi tracker for weekday based automations.

Or, teach your children to switch their phones off when they get to school, and switch them on when they leave, thus keeping their location trackable in case anything happens.

1 Like

Well the tracker is used for all activities past leaving for school. So heading to after school activities and sending notifications they are there or not there. So I still need both. I get why it works this way, but one of the interesting items is if HA is restarted, it uses the stationary tracker and then waits for next GPS update. I would almost question if the person should do the same on stationary trackers when leaving Home. It should wait for next GPS update in my opinion.

Also I’m not disagreeing with your suggestions. Have been pushing different things there as options and likely will not use the person for them at this time until I can get it all figured out.

I just don’t get why they don’t switch their phones off when they get to school, instead of before leaving home. Fixes your problem and has the added bonus of knowing they got to school safely.

1 Like

Two reasons:

  1. They hide them in their backpack and its packed away. They do not want them easily accessible in their lockers and things to discourage theft.
  2. They have forgotten before and got in trouble so they shut them down when they pack them away.

We drive them to school each day so we know they get there. Like I mentioned its not a likely use case that was though of but the same problem would occur if a battery went dead or GPS device stopped reporting in. The data can be stale but how the person is modeled today, its only stale if there is a Home Assistant restart.

Homeassistant’s job isn’t to look after other services. If your reporting method to homeassistant is not working, then it is the reporting method that needs fixing.

In this case you’re deliberately preventing the gps sensor from doing its job, so it is for you to ignore the gps based around your rules for when it will and will not be returning a location.

Maybe have a look at the composite custom component, it gives you more options to combine different sensors together and “aggregates” them into one device. Then you just add that to the person.
I think you can add template sensors or Bayesian sensors. It might get a bit complicated but you should be able to come up with a way for dealing with the school day morning “exception”.

Good luck

Edit:

1 Like

Have you taken a look at monitor.sh combined with the AppDaemon app? Sounds exactly like your use case. :slight_smile:

GitHub - andrewjfreyer/monitor: Distributed advertisement-based BTLE presence detection reported via mqtt

GitHub - Odianosen25/Monitor-App: Appdaemon App for Andrew’s Monitor Presence Detection System

It’s also the role of automation to automate around behavior requirements. So all I posted on here is to look for scenarios and methods to automate around the condition. Just saying, you should have people not do that, is not a way for automation. I can automate as is with device_trackers. My point on the person object is it does the right thing in certain situations (waits for next GPS update vs just transitioning to stale data). I was looking for alternative ways than just behavior changes.

Thanks, I will check this out. I actually was suggested to just go back to a group as well like I used before the person object existed. I might dual setup a few and see how the behavior acts for each in certain situations I am coming across.

Looking at that thread more, this looks close for sure and I might play around with tweaking it. Looks like the OG in this has the same problems I am having with Life360 GPS. I moved away from that because of the issues but opened new issues. So I think a blend of this would be smart because I can control the last trigger setting better then the person object logic is currently doing.

I suggested that in my first reply

Your suggestion that it should mark as away is flawed. Network and Bluetooth trackers drop out all the time, battery saving, glitches, etc. Your suggesting that if I get home from work at 5pm, then at 3am my network tracker drops out for 20 seconds, that I should be marked away because my GPS tracker hasn’t updated for 8 hours. But the fact is I’m still at home. I’d be mighty annoyed when the WiFi reconnected, I was marked back home and the lights switched on!

As I pointed out, it is you who is ‘misusing’ the gps tracker by deliberately leaving the devices unable to update their position, so the system can only plot them at home in that circumstance. It is not for homeassistant to adapt to misuse. It is for you to automate around the information you provide to homeassistant.

I love it!

Think the main issue is device_trackers track a device so when it’s tied to a person’s presence detection it leads to a lot of stretching and assumptions and can lead to all sorts of confusions.
I don’t use them personally (for person’s tracking) so might be all wrong, that’s just my opinion.

I pretty much agree with Marc on this.
But I see yor issue and that needs to be worked around.
You say that they get dropped off at school. Is this by you/your wife ?
If so you might try an automation that detects you/your wife enters the school zone - forces an update on the specific child’s GPS co-ordinates (allows for different children at different schools) to be at that school.
You may have to condition this by time as otherwise it would force the child to be at school when one of you attends a parents evening, but that should not be a major issue as the next GPS update should correct it.

Is using something like Service (device_tracker.see) a possibility if using an existing tracker? My understanding is that would update a device in known_devices but I’m not sure if that works to update an existing GPS device_tracker like one coming from the IOS companion app. I could definitely automate that piece of it. I have many automations based on household and person logic so I would prefer to not conditional all of them with sometimes wifi and sometimes GPS for the other zones I am hitting.

This morning I tried a restart of HA after they were gone to school but ironically the person logic documented didn’t seem to work as it said too.

After some time, both stationary trackers show status ‘not_home’. Now your Person entity has status ‘not_home’ with source ‘tracker_gps’. While you are away from home, your Home Assistant is restarted. Until ‘tracker_gps’ receives an update, your status will be determined by the stationary trackers, since they will have the most recent update after a restart. Obviously, the status will be ‘not_home’.

As for reliability of my home network, I had tuned that with the consider_home setting, Before I was using GPS tracking, I never had false home/away problems and I had conditionals for coming home turning on lights only during certain hours. So most of that I must have automated around to protect those accidental sleeps but Unifi was solid. I had to switch back to NMAP when the unifi component was rebuilt due to the amount of devices on my network but now that its had some heavy updates, I’m back on Unifi for network presence and it seems solid again.

Thanks for all the suggestions to date. I will likely split the person object up or go back to a group for the time being for the kids while I work on some of these other options.