Puzzled by geofence feature

nathanw
Posts: 175
Joined: Mon Sep 05, 2011 3:51 pm
Location: Boston, MA

Puzzled by geofence feature

Post by nathanw »

Okay, I don't understand what geofences are doing. I haven't used them in other apps, so it's possible that Android is to blame....

Anyway, I set up a geofence centered at my house, initially with a 50M radius. Left home and went to work, nothing happened. Came back home that night and an hour after I arrived the "Left home" part triggered six times.

The next morning it triggered twice while I was still at home. I figured 50M might be too sensitive, so I turned it up to 200M. Then it did fire when I left, more or less, but then when I came home the "Left home" fired again twice after I arrived.

(This is all based on notifications on the phone)

On the Indigo side, I see away/home events mostly paired:

Code: Select all

2016-03-03 Events.txt:2016-03-03 20:14:03.445	Action Group	Nathan away
2016-03-03 Events.txt:2016-03-03 20:14:46.164	Action Group	Nathan home
2016-03-03 Events.txt:2016-03-03 20:15:46.981	Action Group	Nathan away
2016-03-03 Events.txt:2016-03-03 20:15:57.418	Action Group	Nathan home
2016-03-03 Events.txt:2016-03-03 20:23:44.948	Action Group	Nathan away
2016-03-03 Events.txt:2016-03-03 20:23:47.432	Action Group	Nathan home
2016-03-03 Events.txt:2016-03-03 20:33:43.147	Action Group	Nathan away
2016-03-03 Events.txt:2016-03-03 20:36:45.104	Action Group	Nathan home
2016-03-03 Events.txt:2016-03-03 20:48:36.776	Action Group	Nathan away
2016-03-03 Events.txt:2016-03-03 20:49:45.113	Action Group	Nathan home
2016-03-03 Events.txt:2016-03-03 20:51:46.710	Action Group	Nathan away
2016-03-03 Events.txt:2016-03-03 20:52:39.753	Action Group	Nathan home
2016-03-04 Events.txt:2016-03-04 06:44:58.050	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 06:45:10.268	Action Group	Nathan home
2016-03-04 Events.txt:2016-03-04 06:53:29.902	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 06:54:34.296	Action Group	Nathan home
2016-03-04 Events.txt:2016-03-04 08:57:13.641	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 18:41:04.854	Action Group	Nathan home
2016-03-04 Events.txt:2016-03-04 18:47:46.919	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 19:14:25.162	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 19:14:34.817	Action Group	Nathan home
2016-03-04 Events.txt:2016-03-04 19:17:43.976	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 19:18:32.195	Action Group	Nathan home
2016-03-04 Events.txt:2016-03-04 20:14:30.540	Action Group	Nathan away
2016-03-04 Events.txt:2016-03-04 20:15:21.450	Action Group	Nathan home
Which also seems wrong, but differently so.

Client is on a Nexus 5X running M, 6.0.1.

Does this make any sense at all?
User avatar
RogueProeliator
Posts: 2538
Joined: Tue Nov 13, 2012 3:54 pm
Location: Baton Rouge, LA

Re: Puzzled by geofence feature

Post by RogueProeliator »

The application isn't actually handling any of the geofence calculations or entry/exit conditions -- it passes that off to the Android system. There are a couple of things that I can think of that may cause this in my experience, but not sure if they apply or not:

1. Having GPS turned off... sometimes the secondary sources (cell towers, WiFi, etc.) are too broad and it can cause jumping in and out of a radius... in this case you might do better with a very large radius (a mile or two?) so that you encompass more tower ranges.

2. Setting the longitude and latitude by using a Google (or other) provider's address search. I experienced this first-hand -- the GPS coordinates for my address put it in the middle of the lot, so about 400' from the road. With my radius set at 300' it still kept jumping in and out inside the house since I was close to the edge.

If neither of these apply, you best bet for debugging is to enable the application to send the location with the status (Settings -> Indigo Status Updates -> Include Location). Then in Indigo log this either with SQL Logger or just with a trigger. If you plot out the coordinates you might see where the phone is saying that you are located and see if it is significantly far off actual.

Adam
nathanw
Posts: 175
Joined: Mon Sep 05, 2011 3:51 pm
Location: Boston, MA

Re: Puzzled by geofence feature

Post by nathanw »

Hmm. I've got the debugging on and logging enabled. Looking at the sqlite dump of the location, a couple of things are notable:
- Friday and today, all the coordinates are near home, even though I've been to work on Friday and out to a few places this morning.

- The timestamps are a little odd. In particular, the "ts" field seems to be UTC, and the "locationfixtime" seems to be local time, but there are some funny relative jumps:

Code: Select all

sqlite> select * from device_history_582671666;
...
480|2016-03-05 15:08:20|91|NotCharging|True|-71.1285586|3/5/16 10:08|42.3987883|Nexus 5X|Paired
481|2016-03-05 18:08:55|91|Charging|True|-71.1285586|3/5/16 10:08|42.3987883|Nexus 5X|Paired
482|2016-03-05 18:08:55|92|Charging|True|-71.1285586|3/5/16 10:08|42.3987883|Nexus 5X|Paired
483|2016-03-05 18:08:55|92|Charging|True|-71.1285586|3/5/16 10:08|42.3994367|Nexus 5X|Paired
484|2016-03-05 18:08:55|92|Charging|True|-71.1267018|3/5/16 10:08|42.3994367|Nexus 5X|Paired
485|2016-03-05 18:08:55|92|Charging|True|-71.1267018|3/5/16 13:08|42.3994367|Nexus 5X|Paired
486|2016-03-05 18:14:50|94|Charging|True|-71.1267018|3/5/16 13:08|42.3994367|Nexus 5X|Paired
...
First local time jumps three hours (when plugged in?) and the fix time doesn't change - I suppose that's possible, but weird. Then the fix time jumps forward three hours just a few minutes later.
User avatar
RogueProeliator
Posts: 2538
Joined: Tue Nov 13, 2012 3:54 pm
Location: Baton Rouge, LA

Re: Puzzled by geofence feature

Post by RogueProeliator »

The timestamp (ts) and locationFixTime are to be expected -- the ts column comes from SQL Logger and always is a UTC time whereas the location fix time is what Domotics Pad is sending to Indigo as provided by the Android system.

So, more details on the location fix time -- Domotics Pad asks Android to give it the last location... and it (Android) provides the time that the location was fixed. Thus, the longitude and latitude provided where determined at that time. What that means is that Android did not fix your location at all during those long breaks in time.

I may have to look into specifically requesting that Android acquire a new fix, but there are implications of doing that (battery life primarily). Let me do a bit of investigating, though, as I see that you are on Marshmallow. It is possible that the Doze feature is doing something in there regarding not acquiring fixes as often / at all.

Do you have fine location / GPS enabled on the phone?

Adam
nathanw
Posts: 175
Joined: Mon Sep 05, 2011 3:51 pm
Location: Boston, MA

Re: Puzzled by geofence feature

Post by nathanw »

I have high-accuracy mode enabled.

What I notice looking at the location logs in more detail is that I only have log records during the times I'm close to home - when I'm away, nothing gets recorded. I don't know if this is geofence interaction or something else.

The home/away thing seems to have been pilot error - I set up a push notification for one but not the other. So now they're more balanced, and it's just the frequency with which the geofence decides I'm out of range, while I'm sitting on my couch, that's kind of weird.
User avatar
RogueProeliator
Posts: 2538
Joined: Tue Nov 13, 2012 3:54 pm
Location: Baton Rouge, LA

Re: Puzzled by geofence feature

Post by RogueProeliator »

What I notice looking at the location logs in more detail is that I only have log records during the times I'm close to home - when I'm away, nothing gets recorded. I don't know if this is geofence interaction or something else.
Hmm, now that is curious as it may indicate some type of bug in the service not switching to the Away mode. I assume you have separate Home and Away addresses in the settings? Are you using the Reflector service?

Adam
rhanson
Posts: 198
Joined: Tue Apr 30, 2013 6:31 pm

Re: Puzzled by geofence feature

Post by rhanson »

I suppose this would be a good time to mention that the state values for lat/long appear to be swapped. That is, the value of the "latitude" state is actually the longitude. My current "latitude" is -117, which would be very far south, and require a planet shaped like a cashew or something to get past 90 degrees. lol

Just in case anyone's planning on scripting based on these states, you may never find yourself where you expect to be. :-)
nathanw
Posts: 175
Joined: Mon Sep 05, 2011 3:51 pm
Location: Boston, MA

Re: Puzzled by geofence feature

Post by nathanw »

I do have separate Home and Away addresses, and I'm using the reflector. How does DomoPad try to decide which one to use?
nathanw
Posts: 175
Joined: Mon Sep 05, 2011 3:51 pm
Location: Boston, MA

Re: Puzzled by geofence feature

Post by nathanw »

In fact, right now I'm at my office, a few miles away from home, and have been away from home for about an hour. DomoPad's settings has auto-switch location enabled, but Current Location says "Set to use Home IP and Port".

What is the switching logic?
nathanw
Posts: 175
Joined: Mon Sep 05, 2011 3:51 pm
Location: Boston, MA

Geofence update bug (was Re: Puzzled by geofence feature)

Post by nathanw »

A ha, here's an actual bug: if you edit the fence geography of an existing fence and click the checkbox, the actual geofence in Android isn't updated. So all of my complaints about the continued twitchiness of the at-home sensing was probably because it's been on the 50-meter radius the whole time, and my various updates to 250, 500, 1000 meters never took effect.

I checked with this bit of debug magic:

Code: Select all

adb shell dumpsys activity service com.google.android.gms/com.google.android.location.internal.GoogleLocationManagerService
which shows things like:

Code: Select all

Active Geofences:
    Package: com.duncanware.domoPad, count: 1
        Geofence[CIRCLE id:1 transitions:3 42.399511, -71.126702 50m, resp=0s, dwell=-1ms, @-1] it=5, d=5157 OUT
A workaround is to uncheck the "Enabled" box and then save, and go back in and re-enable and save (which pops up the "Geofence disabled/enabled successfully" toasts).
User avatar
RogueProeliator
Posts: 2538
Joined: Tue Nov 13, 2012 3:54 pm
Location: Baton Rouge, LA

Re: Puzzled by geofence feature

Post by RogueProeliator »

In fact, right now I'm at my office, a few miles away from home, and have been away from home for about an hour. DomoPad's settings has auto-switch location enabled, but Current Location says "Set to use Home IP and Port".
What is the switching logic?
The main application will automatically attempt to change over to the Away address if it is unable to reach the Home address... but only when the application is open. The Geofence Actions actually always use the Away address (if set) under the assumption that most of the time a geofence transition will occur when away from home. HOWEVER, it looks like the status updater does not have this "forced" Away address use -- hence, it is likely using the last location found. This will be corrected in the next update.

Adam
User avatar
RogueProeliator
Posts: 2538
Joined: Tue Nov 13, 2012 3:54 pm
Location: Baton Rouge, LA

Re: Puzzled by geofence feature

Post by RogueProeliator »

A ha, here's an actual bug: if you edit the fence geography of an existing fence and click the checkbox, the actual geofence in Android isn't updated. So all of my complaints about the continued twitchiness of the at-home sensing was probably because it's been on the 50-meter radius the whole time, and my various updates to 250, 500, 1000 meters never took effect.
Excellent catch -- this might have been the cause of a previous user's issues with geofencing as well since the first problem was a too-small radius. I have it fixed for the next build, probably to be released this weekend.

Adam
Post Reply

Return to “DomoPad Android Client”