hepcat72 / node-red-contrib-life360

GNU General Public License v3.0
3 stars 4 forks source link

Possible issues with events for overlapping/redundant places in different circles #11

Open hepcat72 opened 2 years ago

hepcat72 commented 2 years ago

I have not confirmed yet that this is a real issue, but here's what I did and what I was seeing:

I took advantage of the fact that I have 3 circles to create 2 geofences for my home (in separate circles), one larger than the other. I have a large diameter geofence in order to turn on my air conditioning as early as possible when I'm headed home and one to do other things like turn on flood lights and control my security system.

When I set up the second (closer) circle, I just set it up to control the flood lights, but many times, it did not seem to work. At first, I chalked it up to a fluke, or maybe I was on the phone (cdma network means no Life360), but to debug after awhile, I switched it back to my original circle that controls everything else, and have noted that it works very reliably.

So I'm not really sure what was happening and I need to do some thoughtful debugging to see if I can figure out whether 2 overlapping geofences in separate circles is really a problem or not...

rathga commented 1 year ago

I have a similar problem but with overlapping places within the same circle. I see in the code you are using location.name to determine the place of a given member. Have you considered changing this to calculating what places a given member is located in based on their longitude & latitude together with each place's respective longitude & latitude and radius? I'm happy to have a stab at this, and maybe it would fix your problem too (?).

hepcat72 commented 1 year ago

Interesting idea. Honestly, I would have to know more about Life360 to know if that strategy could work well. I believe Life360's assignment of location.name is likely to be a good bit deeper than a simple distance (given noisy and faulty data) and I somewhat think that reworking that could be like reinventing the wheel a bit...

But... if one was to take a stab at this, I think it could make use of the named places data. What's really needed is for location.name to be an array containing potentially multiple locations to handle overlapping geofence perimeters. If you had the place data and a person's current location, you could ignore the current location.name and populate a new value: location.names based on a distance calculation for each place to see if it's shorter than each place's geofence radius.