So just an update for everyone as I’ve been tracking a problem I had with two phones and Geofencing that will hopefully inform everyone as to the multiple gears involved. While this isn’t necessarily the solution to ALL the problems, they are some of the most common.
To start with, this is the order of operations on how GeoFencing works with Mobile Presence (smart phones)
- Smart things polls the GPS location of the device repeatedly.
- If the latitude / longitude coordinates were previously inside the geofence and are now outside, it triggers an Exit Event (or Enter event for vice versa)
- on phones, the triggering of this event is a web request to Smartthings website.
- once the website receives the request, the event is transmitted back to your your Hub, where your hub will perform various automations based on the Enter / Exit event.
There are two major things that can interfere with this operation.
1) Accuracy of GPS location.
Phones report GPS location as three numbers. Lattitude, Longitude, & Accuracy. This is where your phones GPS setting comes into play. This is from the log file of the Geofencing within the Smartthings app.
Tue 18:46:31 Event fix: 31.4655, -82.5144, acc= 17.0m
You can see that the reported latitude is 31.4655, and reported longitude is -82.5144, with an accuracy of 17.0m. This means that your phone is somewhere within the radius of 17m from the GPS coordinates of 31.4655, -82.5144. Most of the time this is accurate enough to register location changes. Problems start to occur however when the accuracy goes up, due to your phone not getting a good lock on the GPS satellites, in which case it falls back to the location of the cell tower that you’re connected to. In this case, it will report the GPS coordinates of the cell tower, with a much higher accuracy since you have to be within that range given that your phone is connected to it.
Here’s an example when my phone fell back to the location of the tower
Event fix: 31.4552, -82.5292, acc= 3260m
As you can see, the accuracy is a radius of 3000 meters, which is a huge swath of area. This is where your reported location, and your actual location, can very greatly, and can affect whether your inside or outside your geofence.
I’ve (crudely) drawn some examples that show how this can affect things.
Starting with an example house with a 500m radius GeoFence
Now first example is a phone’s actual location (x), and it’s reported location (triangle) in relation to the geofence
You can see that there’s no issues.
Second example shows a phone actually inside the Geofence, but due to the low accuracy (high accuracy number), the reported location is actually outside the geofence,
so while you may indeed be standing inside it holding your phone, your reported location is actually outside the geofence, so none of the automations that rely on being inside the fence are triggering.
This is not something that can be helped by Smartthings, as they rely on the location reported by your device. Smartthings can’t control your device and how accurately it decides to report it’s location.
2) Web requests not completing
This is something that I recently contacted Smartthings about, and have seen referenced a few times here and there. As part of the events triggering, your phone sends a web request to a Smartthings url reporting the phone either entering or leaving. If the phone cannot send that request for whatever reason, then your automations will not trigger. Examples are being in airplane mode, having low/no signal, etc… Just like you couldn’t load a web page, the Smartthings app cannot send the information to it’s servers to show that an event has taken place.
With the release of Android Nougat, I confirmed with Smartthings that Doze may be interferring with these requests and not letting them complete. I have been told their Engineers are working on it, and will at some release an updated app that will account for Doze, but until then, if your phone is in sleep mode, know that the request fired off to the servers when an Enter/Exit event occurs, may not actually get there, thus not triggering any automations.
There is a way you can disable Doze for particular apps (reference: http://www.greenbot.com/article/3112224/android/what-you-need-to-know-about-doze-mode-in-android-nougat.html ) and I have disabled it specifically for Smartthings, so we’ll se what that does as far as preventing it from sending requests or not.