Is it possible to track location via zone only?

Tags: #<Tag:0x00007f47ff79efe8>


It’s really nice to have the iOS app taking care of location tracking for me, but for a variety of reasons, I’d like it to update only with zone entrances/exits — my family is pretty privacy-conscious and I’m much more comfortable just showing when people are in one of the several zones I’ve set up or are “away.” I’m using v1.5.0, and I have updates unchecked for all except for zones, but the map and location tracker objects are still showing gps coordinates beyond them.

I’ve also noticed that the new location services change has the app using a TON more battery than before. Is there a way to mitigate that?



I don’t know about any special features of the iOS app, but for GPS-based device_trackers in general, the way they work are, they only know when a device is in a zone by first knowing their GPS location, and then comparing that to the known zone locations to determine if the device is in a zone.

It might be possible, though, to modify the way the device_tracker component level code works to add a feature that hides the GPS coordinates (i.e., doesn’t expose them as device_tracker entity attributes) until the device is in a zone. Or maybe a feature that just outright always hides the GPS coordinates. Either probably wouldn’t be too difficult to implement. But that’s a feature request. :slight_smile:


I exclude the device_tracker domain from my recorder and I use a card like this (and no map) to show only the zone someone is currently in:

  - id: people_location
    type: entities
    title: Where is everyone
    show_header_toggle: true
      - device_tracker.mqtt_richard
      - device_tracker.mqtt_sandy

Yes I know the lat/long is still observable in the attributes but that takes a bit of effort.


I assume that’s Lovelace? I don’t use it, but in the “regular” UI, all you have to do is click on the entity and a window pops up with more details, including the GPS coordinates. Is that not also possible in Lovelace?


Yes but you can set the style: to be pointer-events: none to turn that off. (In lovelace)


That makes sense. My hope is that having the iOS app configured like this, it just uses geofencing instead of having HA do the math for the zone.

Ideally, it wouldn’t even need to send true coordinates, just zone_entered or zone_exited, especially since iOS has geofencing APIs built-in. As it is, I’d thought that this setting would only send location updates when it senses zone enterance/exits. If not, that’s okay, I can just use the tricks above to mask it but it seems a lil hacky, and if rather just not waste data sending updates that’ll just be hidden away anyways.


Forgot to attach screenshot:


FWIW, I did a quick experiment. On the States page I clicked on a GPS-based device_tracker (that was not currently in a zone), then changed its attributes by removing longitude, latitude and gps_accuracy and clicked SET STATE. Then I went to the map and sure enough the icon for that device_tracker was gone. The icon for the device_tracker in a “regular” view was, of course, still there, but when I clicked on it the GPS coordinates were gone. Of course, as soon as the device_tracker updated itself it reappeared on the map and the GPS coordinates came back in the regular view.

If you’re comfortable editing Python code, it should be extremely easy to prevent the GPS attributes from being added to the device_tracker entity in the first place when it’s “Away” by modifying this line. Change it to:

        if self.gps and self._state != STATE_NOT_HOME:

I haven’t tested this, but it should work, allowing the GPS coordinates to be shown in attributes only when the device_tracker’s state is not “Away” (which typically means it must be in a zone.)

Now, having said that, there are several reasons why this might not cover all the bases. First and foremost, some device_tracker platforms provide other attributes (such as address) that might give away the device’s location, even if the GPS coordinates themselves are not shown. Next, some device_trackers (such as my Life360 platform) can change the device_tracker’s state to something other than ‘not_home’, even when the device is not in a zone, so the simple test above would not cover that case.

I do think it would be a nice feature for the device_tracker infrastructure to support the ability to hide a device’s GPS location when not in a zone (or maybe always), even though it still has it and uses it “under the hood”, but to implement that properly and completely would be a bit involved.


Oh wow, you did some serious digging, I really appreciate it! I’m away from home for a little ways but I’ll try out what you found ASAP and report back.