Person entity is never showing "away"/ "not_home"-- going from one zone to another. This is an Android phone

Hello all,

Could I get some guidance on what is possibly going on with the subject/ image below?

Are there any ways to correct this as I would really like to know when the device leaves the home zone. Based on looking at the times shown by the person sensor, the sensor missed the leaving home and drive time to work (around an hour) and just showed “home” during that time, then immediately transitioned to the zone “work” once she arrived there.

One possible cause would be that the doesn’t have a connection. This can be caused by anything that tuns Mobile Data off or if the device is WiFi only. Often the best option is to add a stationary tracker to the person entity. There are a variety of router or Bluetooth-based integrations you can use to create stationary trackers.

first check the device tracker is configured properly https://companion.home-assistant.io/docs/troubleshooting/faqs/#device-tracker-is-not-updating-in-android-app

if that doesnt work then check the person entity configuration and remove any device tracker that stays at home, for example if you logged into a tablet dont leave teh tablet attached to your person entity.

Ahh, thank you for these ideas. I will see what I can come up with on these over the next few days. I have the google wifi mesh routers so I will see if I can use those somehow.

I follow you on these. It looks like I have things setup properly. The only device tracker behind her person entity is the mobile app cell phone one. I noticed last night that things worked properly as she came home so I’ll just have to look at it over the next few days. Maybe the first instance was just a fluke.

@Didgeridrew @dshokouhi

Just giving you all an update to see if you all have any other thoughts on this one.

Below is this mornings situation. It looks like it did the same thing which is blowing my mind. home zone to work zone with no “away” in between the 2 zones. Yesterday afternoon leaving work, it looks to have caught leaving the work zone and it kicked to “away” as should be expected and then “home” when arriving home.

I’m at a loss on this one.

please do not forget about the link I shared, you stopped reading at the second most important part. Location tracking history that paints a clearer picture of the issue. Do you see failures in that history or just time gaps?

I’m not sure whether you would call it a failure or a time gap.

This morning, similar to yesterday morning. The device tracker only updated when hitting the work zone. So the tracker went from home zone to work zone, rather than home, away, work. The time the work zone became active was the time the device tracker actually hit the zone but there is no instance of the away zone being shown which should have occured directly after leaving the home zone (about an hour before the work zone shows “hit”.

I will check these tonight and see what happens tomorrow morning and report back.

If you find that the device tracker is not updating as you would expect follow the below steps to ensure optimal settings.

Make sure your device and server meet the prerequisites for location tracking:
Enable remote access for your server.
In Settings > Companion app > Manage sensors, enable the following Location sensors: Background location, Location zone and Single accurate Location.
If you use multiple servers, make sure the correct servers have each sensor enabled.
If you did not install the app from the Play Store, verify that you are using the full flavor.
Ensure the app has location permissions granted, all the time. (On Android 12 and newer, allow Precise location when prompted)
Ensure that location (GPS) is enabled on your device.
Allow background access and turn off 'battery optimizations' for the app.
You can check background access in Settings > Companion app. The setting should show a check mark ✔️.
Some manufacturers may add additional battery saving features (ex: Power Saving), make sure to disable all of those as well. You can usually access these from the system settings app.
Turn on unrestricted data for the app.
Samsung devices: you will need to disable data saver for Home Assistant as well.
Sometimes the above steps will still not result in location updates reaching your server. The app can receive a lot of location updates and may skip some of them. To determine why, review the app location history logs.

Go to Settings > Companion app > Troubleshooting > Location tracking and enable location history. The app will now keep a log of all location updates received in the last 48 hours.

Each update will show the source (for example, "Background location") and result (for example, "Sent"). The app verifies that a location is valid before sending it, and an update may be skipped due to time, accuracy, duplicates, or other reasons.
The app should receive updates multiple times an hour. If you do not see updates after enabling the history, make sure to follow the previously mentioned steps. No location history is usually caused by limited background access for the Home Assistant app, or the Android system killing the app.
If multiple updates are skipped due to accuracy then check the GPS coordinates to ensure they were correct, and consider increasing the sensor setting for accuracy. For example, if you see a valid location getting skipped with accuracy around 350 then set the minimum accuracy setting to 400 as a buffer. Larger values may also lead to inconsistent results so go by valid reports in the logs.

thats what history will show, basically teh way location tracking works is that the app registers for updates from Google and depends on Google to send those updates. In the logs you should expect to see updates coming every few minutes (1-3 minutes or faster if shes using google map or similar for navigation). Every report received by google gets evaluated to see if it is a valid report and gets tracked. We show if the report was skipping, sent successfully to the server or the server failed to get the update.

if you want to understand more about how location tracking really works under the hood this link explains it https://companion.home-assistant.io/docs/core/location#android-location-sensors

depending on what you see in history will determine next steps.

ok. I believe I am following you now.

So by history, you don’t mean the graph I keep posting.

You mean the info spoken of below?

Go to Settings > Companion app > Troubleshooting > Location tracking and enable location history. The app will now keep a log of all location updates received in the last 48 hours.

I will get this setup also and report back with the info over the next few days.

Thank you for your guidance with this.

yes and its enabled by default too

Oh, ok. Good deal. I will take a look at this tonight. There is definitely something strange going on.

I have a map in my dashboard. My person entity has a location dot every few minutes. If I was guessing, every 5-10 minutes. Hers has one at the start of the drive and end of the drive.

Theres a lot of factors at play here which is what hte history will show

  • Did google send an actual report (time gap)
  • Report failed to send to server (will need to reproduce and check logs under troubleshooting section for the actual failure)
  • Report skipped due to time (nothing you can do as we do report validation and we do get very late reports)
  • Report skipped for duplicate (expected state, we dont send duplicate location updates for 15 minutes)
  • Report skipped for accuracy (if this occurs check the second link i sent specifically about sensor settings as you will need to adjust the accuracy level to be higher than the default )

I follow you. Would you say I should follow the below first (before I start). Check it for a day or 2 and then post the history if the changes below don’t resolve the issues. I have a feeling they will.

yes definitely, check the steps then go to location tracking history and make sure you see updates there so you know its working so you can check the history later when the issue occurs and research from there.

I did not fully read all the posts, so sorry if I missed some one saying the same:

Two things should be separated. If the location is updated way too little, look into that. But if zones are close, even with frequent updates the state of a tracker will never be not_home.

You should set up your automations not to depend on not_home / away states. For zones, use the zone state as much as possible to see things like first person entering or last person leaving. The state is a person count. There’s also an attribute with names. Last person leaving home:

platform: state
entity_id: zone.home
to: "0"
not_from:
  - unavailable
  - unknown

You could also use a numerical state trigger, I personally prefer this. As a condition, you can use a for with state conditions to put in a delay, with a numerical state condition you can’t.

For singular persons leaving you can use a state trigger, e.g. from: home, not_to unavailable or unknown. For entering you can use the reverse: to: home, not_from unavailable or unknown. Me leaving home:

platform: state
entity_id: person.me
from: home
not_to:
  - unavailable
  - unknown

No problem.

I’m starting to think this is my issue.

I follow you here.

Thank you for adding value here. I understand what you are saying and I will be sure to apply these concepts as I create new location/ zone based automations.

1 Like