Remotely enable location tracking

I’m investigating using HA as a ‘lightswitch’ to facilitate handling a lost phone. I normally do not keep wifi/bluetooth/gps enabled while out and about, and this poses an interesting catch 22 - its “safer”, but if I lose my phone I can’t use any of the ‘find my phone’ features built into android because they require gps to be on.

Is there a way to toggle gps on and off using the home assistant app, if it’s given the proper permissions? I’d love to be able to mash a button in HA, have gps come on, and then have google, tile and whatever else plots phones on maps “suddenly start working”

I’m pretty sure a lot of that will be limited by android permissioning itself rather than ‘can HA do it’. I think you’ll find without root, nothing can toggle gps and wifi on/off on recent versions of android. If you rooted your phone though you could create a tasker or automate for android flow and call it from Home Assistant intent.

thats not a bad idea! I do have tasker installed, and I’m currently using it to light up wireguard when I drop off my home wifi network - thats what lets me talk to HA when not at home. I’m pretty sure tasker can turn on gps without needing root, though I’m not opposed to rooting for other stuff (mostly adblock related)

If you have an example of using tasker and HA together, that would be super handy!

I’m pretty sure tasker loses the ability to toggle gps without root in recent versions. That’s what I meant about is an android permission issue and not a "can HA do it"thing.

if you turn off location remotely then you will need to re-enable location tracking as the app will no longer have permissions and thus the sensor is turned off. You will need to manually enable the location sensor again.

I do this with Tasker. My wife and I share a truck so I have two cheap Roav chargers in my truck that projects bluetooth signals. When our phone connects to the charger assigned to us it tells Tasker to turn on on High Accuracy mode (no root needed). I would do this with our radio but the radio only accepts one connection at a time and bluetooth scanning for bluetooth near is too battery intensive.

When our phones disconnect it turns the GPS back to device only (this is really not that battery intensive btw, but you can set it to off as well.) The advantage of doing it this way is we still have trackers outside of the truck, i.e. out on walk where high speed, high accuracy mode is unnecessary.
.
You could do this with a notification in home assistant.

    action:
      - service: notify.mobile_app_<your_device_id_here>
        data:
          message: GPSon
          title: Tasker
          data: 
            channel: Tasker

Set up an event in Tasker looking for the notification with the message GPSon, have this trigger Tasker to turn your GPS on. You could also have Tasker clear any notifications with the title Tasker. By setting the channel you can turn the sound off, and minimize the notification.

Just go in reverse to have it turn off GPS.

(Before moving to Home Assistant I use to use Tasker as our presence detector with the autolocation input and having Tasker send webhooks to virtual devices on Hubitat. The roav chargers turned autolocation off and on. I found now that using the companion app and having Tasker go into and out of high accuracy is more reliable and even less battery intensive, as Autolocation really any Taker input is battery intensive even with the geofences off.)

FYI I have no issues turning this on/off on a Samsung device as always with Android your miles will vary but this is possible without root. I did have to provide Tasker SECURE_WRITE_SETTINGS with adb but that’s easy.

1 Like

Hey, thanks! I’ll give this a shot and post here what happens :smiley:

I will say that after a couple of days of full testing of the home assistant companion app that it in no way can compete with the accuracy of autolocation. I always had autolocation on a 5 second interval when in the truck which isn’t an issue when you just plug in, and you’re using GPS already.

I didn’t want just autolocation though because autolocation only uses a toggle to trigger into and out of zones. I quite like the person integration with the map.

So last night I created my own Tasker presence sensor that tracks and sends GPS lat and long into a text input in Home Assistant, every 5 secs. I made a variable that is either 0 or 1. 1 means I’m connected to the Roav charger. If I’m connected to the Roav charger Tasker uses it’s built in Get Location function every 5 seconds and sends that data to Home assistant via json data. Lat goes to one text input, Long goes to another. I have a device_tracker.see automation that looks for updates to these inputs and uses those GPS coordinates, then linking this tracker to my person, disabling the companion app from doing it…

Granted I lose the ability to do this when outside of the truck but that’s another problem for another day. Neat little thing that comes of this…when I disconnect from the truck I have it do another get location before exiting the task so the Home Asssitant map will always show my trucks parking spot.

Watching my map I think that the companion app must grab any location that other apps request as well. When the created device tracker updates the phone immediately updates right behind it. I may not even need the virtual tracker if this is the case. I’ll just have Tasker running the getlocation every 5 seconds and the companion app should pick those updates up. I have commands set up to have this on High Acc/5 seconds intervals via a HA automation but it doesn’t appear to be updating that fast at all. I’ll keep testing as it’s fairly easy to turn off and on tasker things.

Did you look into high accuracy mode from the companion app? It updates every 5 seconds using gps.

Indeed it does, you should read the companion docs to understand how it works.

As part of companion troubleshooting we need to see the logs to understand why it’s not updating every 5 seconds. I think you should take sometime to read the docs to fully understand what you can do and how to fix issues you see.

I’ve been through the docs. I did see the command update interval as part of the high accuracy mode. I had a webhook setup to trigger this off/on when leaving the house on both phones, along with setting the interval to 5 seconds. I have 30 second delays on my presence automations so that there’s time between delayed GPS reporting. I even have tasker setting high accuracy mode. Without fail one of was going not_home before the other. Coming home when I used autolocation I had it timed where the door would unlock when I pulled in the driveway. Now I can wait an extra 30 seconds or so. I did not see any errors in the logs and the command message wasn’t coming as a normal notification.

I will say that after clearing the data on the app last night. I noticed on my way home a notification for high accuracy mode that I hadn’t seen before, with the lat/long updating fairly frequently… Interestingly this was also new on my wife’s phone without having to reset her phone’s app. I was thinking of trying this again with just the companion app.

its not just about error messages but there is an entire location decision making process to help troubleshoot these issues. That is why the troubleshooting step shows what correct logging looks like. The logs tell the actual story about what is going on as we print everything.

Ok that makes sense. When my wife gets back with the truck I’m going to run some tests and see if it’s working. If not I’ll report back.

1 Like

I’m not sure why or what had happened before but everything works now as expected. A much better integration than Autolocation/Tasker…

@dshokouhi Speaking of Presence in Home Assistant. If I understand the docs correctly…if I create a Person…“family” and attach all devices to that person…“family” will be home until all of it’s devices are gone, correct?

Why wouldn’t you have each person as their own person so you can identify them separately, then group them? or use the zone.xxxx to determine how many are still there?

I do have each as their own separate person. I was then going to create a family “person” for when both leave together, with the kids (who aren’t old enough for presence sensing yet lol so they are always with us if we both leave, except for when there’s babysitters but I have booleans for that lol).

zone with the number works for my work zone as I’m the only one who goes there. It doesn’t work for the house. We have a fi tracker on our Husky (he’s listed as a person)…he could still be home or with us when we leave. My Viper smart start is also listed as a “person” and due to api call limits it only scans every hour. So it randomly leaves while we are out.

You could just create a group of the persons you want to track. No need to really duplicate ‘another’ person for a ‘family’.

Not exactly topic related, but definitely related to last post ^.

My kids don’t have a device, and will either be with me or my wife, or could be at home with In-Laws when both my wife and I are out.

Could a person’s tracking device be toggled in dashboard/animation/ schedule depending on the circumstance.

  • with me = Android phone
  • With my wife = Iphone
  • Grand Parents (at home)

I assume you aren’t referring to that happening automatically. If so, just setup an input_select helper.