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.