Make the HA Companion App detect arrive home fast enough to turn off the alarm before I enter?

I’m in the progress of moving to Home Assistant, so far it’s awesome and I’m loving the android companion app.
However it usually doesn’t detect I’m home fast enough for my alarm to turn off before I open the front door.
With the new 3.0 version of the App, I was wondering what strategies you have used to get fast location updates?

Currently I’m using Tasker to determine whether I’m home or away.
I configured it so that when I am less than 2km from my house, it checks the location of my device more frequently.

I would like to move away from Tasker and use the home assistant companion app for this.

One approach would be to create a ‘near home’ zone in home assistant that is for example 2 kilometers.
I can then create an automation in home assistant that runs every 30 seconds when I’m in the ‘near home’ zone but not in the ‘home zone’ which uses the accurate_location

Another appraoch, if the above solution is too battery intensive, could be to create an automation in Home Assistant that requests the Companion App to send a location update when I open the front door to make sure I didn’t just arrive home before I trigger the alarm.

What I haven’t figured out is how to have home assistant request the Companion App to send an accurate_location update. I found documentation on how to do it with tasker: https://companion.home-assistant.io/docs/core/location/#sending-an-intent
So I could have home assistant ask tasker to ask the companion app to send a location update. But that defeats the purpose of doing away with tasker.

In Tasker I save a lot of battery by having a setting enabled so that the location is only fetched and sent when the motion sensor detects motion. Could I achieve something similar by having my automation in home assistant check the value reporter by the companion app for detected_activity to see whether I’m on the move?

Just use the WiFi connection sensor instead of device tracker app it updates the moment you connect to WiFi.

My house is full of concrete and rebar, so the WiFi doesn’t reach outside, and some of the locations where I enter the house don’t have any WiFi either. So in my particular case relying on the WiFi isnt the best option.
I also use the automation to get an actionable notification whether I want to open the garage door. That too would require getting the notification before I am connected to the WiFi.

I’d love an answer to this using location services, as I have wifi in the car - so connection to wifi won’t work for me. I’ve tried the HA app, GPS logger, Tasker, etc and none of them work consistently on Android.

one thing you can do is inspect the logcat logs on your device after you arrive at home to see how fast it detects you. Use an app like logcat reader and after granting the permissions you can search for LocBroadcastReceiver and you can see if we are skipping events or not. There was an important bug fix in the latest beta that you can try as well to see if it works better for you too.

Also double check: https://companion.home-assistant.io/docs/troubleshooting/faqs/#location-is-not-updating-in-android-app

If I use GPS while I drive home then it usually disarms as I park outside.
My home zone is 150 m and that seems enough while using the GPS.
If I don’t use the GPS then it usually does not disarm the alarm.

This is because when you use another app that requests for an active GPS location we get those updates passively every 30 seconds (this is what the latest beta fixed). When you don’t use another app it goes back to the normal 90 sec to 3 min interval. Make sure to check the above link and possibly consider increasing the required accuracy for the 3 location sensors

Unfortunately for me it’s been the opposite. Since v3.0.0 I haven’t been able to get fast home arrival detection working like it used to. I think I’m doing everything right:

  • Phone is connected to an always-on VPN into home network, no issues with UI or other sensors
  • App has access to run in the background
  • Battery optimisation has been disabled for this app
  • Home zone is pretty big, 140m radius
  • Actively using GPS navigation whenever returning by car
  • Tried app in background, foreground, and android split screen
  • Tried increasing location background/zone min accuracy up from 200 to 2000

And yet I’m consistently only getting the home state updating 1-3 minutes after actual arrival. Sometimes I get a direct state change of work->home with no away state despite a 15-20 minute commute with active navigation.

Any tips on how I could debug this?

Please try the latest beta.

You guys should try using the Baysian sensor to determine home presence, I have 3 device trackers in it

  1. WiFi
  2. Bluetooth and
  3. GPS, this way the second I am home it shows.
- platform: bayesian
  prior: 0.6
  name: Dad Presence
  device_class: 'presence'
  probability_threshold: 0.9
  observations:
  - entity_id: 'device_tracker.dad_gps'
    prob_given_true: 0.9
    prob_given_false: 0.4
    platform: 'state'
    to_state: 'home'
  - entity_id: 'device_tracker.dad_bt'
    prob_given_true: 0.9
    prob_given_false: 0.2
    platform: 'state'
    to_state: 'home'
  - entity_id: 'sensor.dad_wifi'
    prob_given_true: 0.9
    prob_given_false: 0.2
    platform: 'state'
    to_state: 'Study'
3 Likes

If I understand this correctly, if all presence sensor are false, probability will rest at 0.8. Any individual sensor being true raises the probability above 0.9, so isn’t this acting as 3-way OR logic? What is the benefit above using a template here?

Yeah sort of, It measures the probability of each sensor and acts accordingly. So as your issue above is sometimes your GPS does not update fast enough with this you connecting to bluetooth and wifi would be enough for HA to assume you are now home and not wait for the GPS to update.

Sample size of 1, but it worked perfectly today. Thanks.
Edit: Continuing to work perfectly for the last 2 weeks.

hi quizzical, i’m a bit of a noob, but i didn’t quite see the answer to your question, so i’ll give it a shot.

first, the actual issue might be in your app settings on your mobile. by default location sensors are off so you need to go and turn them all on. in android, app configuration->manage sensors->location sensors… turn on all 3 (background location, location zone and single accurate location). you’ll find the equivalient on ios, although slightly different.

that should make things more responsive and trigger as you enter/leave zones.

however if that doesn’t work for you, then to answer your embedded question of how to cause home assistant to request an accurate_location update, here’s the yaml:

service: notify.mobile_app_your_device
data:
  message: request_location_update

one caveat is that you’re limited to notifications/day. so you don’t want to be hammering this.

i hope this helps, and i hope i got that all right. i’m sure someone more experience than me might correct any errors i have here.

3 Likes

Thank you @armedad, this is very helpful.
I will use this to trigger a location update request when the alarm is triggered while we are away. If it turns out we just arrived home, it will disarm the alarm.

Have you considered adding a short delay as well? Maybe incorporating the wifi connection sensor which updates immediately upon a state change? Personally I found adding a short delay fixed the false alarms.

1 Like

Thanks for the suggestion, I have installed the unifi integration so if my mobile phone manages to connect to the WiFi network during the period that my alarm is pending (i.e. it has detected me and indicates it will go off in 30 seconds) the alarm will disarm.

There is a sensor in the HA app also.
I believe it’s much faster than 30 seconds.

1 Like

The issue is more that if I enter trough my garage, the alarm system will detect that while I don’t have good wifi in the basement :wink:

That being said I am a bit curious whether there are pro’s & con’s over using the wifi connection sensor for presence detection rather than the Unifi integration which I’m using now.

Then get an access point or router (that you configure) and place it in the basement