Life360: Feature Request: Temp Geofence

Posted on
Wed Dec 27, 2023 7:33 pm
whmoorejr offline
User avatar
Posts: 763
Joined: Jan 15, 2013
Location: Houston, TX

Life360: Feature Request: Temp Geofence

Trying to wrap my head around a way to make a temporary geofence on the fly. Like a one button solution.

Example use:

Kid1 gets dropped off at a friend's house for a playdate. Press an indigo button to run an action. Action creates a temporary geofence that has triggers and notifications already associated. If Kid1 travels XX distance from the temporary location (friend's house) then a nofication action is triggered.

Another similar but different problem.... (One which I have no idea how to implement)
Link two or more devices on the fly. A couple use cases for this:
1) Family outing.... press a button that links two or more devices (which means there would have to be a selection process of some sort or multiple pre-created actions grouping devices)
run the action and now if those two devices travel too far from each other, a notification is sent.

2) Traveling with two devices (ie, work phone and personal phone). Link the two while you are out, so if one device mistakenly gets left behind in your hotel room or in the rental car, you will get a notification that the devices have become separated.

Bill
My Plugin: My People

Posted on
Sat Dec 30, 2023 2:42 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Life360: Feature Request: Temp Geofence

What would be the "button" method for requesting the fence to be created ? Does the device itself support at button ? I'm assuming it wouldn't be very helpful unless it was accessible through Indigo Touch.

If the "button" doesn't send the device information to the plugin automatically then there would be a need for a popup to collect info, which makes this feature less useful.

Posted on
Sat Dec 30, 2023 3:37 pm
whmoorejr offline
User avatar
Posts: 763
Joined: Jan 15, 2013
Location: Houston, TX

Re: Life360: Feature Request: Temp Geofence

Soft button… like on a control page that runs an action or a script to get the ball going.

I’m trying to find my old triggers I was tinkering with before you added custom geofences. One issue I had with triggers is that occasionally, the location comes back as “null” or something to that effect.

Edit: The is what I have thrown together so far (untested)... but it looks like to get a working prototype, 1 action and 1 trigger per device to "GeoLock" them to their current location.

I have an action that runs a script to populate a couple variables and enable a trigger.
Code: Select all
###Save Device location to variables:

location1 = indigo.devices[1986325525] # "Life360 - Bill"
lat1 = str(location1.states["member_lat"])
lon1 = str(location1.states["member_long"])
indigo.variable.updateValue(1649518735, value=lat1) # "BillSavedLat"
indigo.variable.updateValue(14927307, value=lon1) # "BillSavedLong"


This enables a trigger. The trigger has a python script as a condition. Whenever my "Closest address" has any change, the trigger should compare my currentl location to my saved location and then send a notification if my current location is greater than 2 miles from my saved location (which could be tweeked in the script)

Code: Select all
from math import sqrt, cos, radians
distanceLimit = 2   # <-- quantity, select miles or kilometers below

# Life 360 Member Device Current Location
location1 = indigo.devices[1986325525] # "Life360 - Bill"
lat1 = location1.states["member_lat"]
lon1 = location1.states["member_long"]

# Life 360 Member Device Saved Location
lat2 = float(indigo.variables[1649518735].value) # "BillSavedLat"   
lon2 = float(indigo.variables[14927307].value) # "BillSavedLong"

R = 6371  # radius of the earth in km
x = (radians(lon2) - radians(lon1)) * cos(0.5 * (radians(lat2) + radians(lat1)))
y = radians(lat2) - radians(lat1)
kilometers = R * sqrt(x*x + y*y)
miles = kilometers * 0.621371

if miles >= distanceLimit:  # <-- change to kilometers or leave as miles
   return True

else:
   return False

Bill
My Plugin: My People

Posted on
Sun Dec 31, 2023 10:54 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Life360: Feature Request: Temp Geofence

I took the first stab at this Dynamic Geofence feature. You can find it here:

We will still need to figure out how to trigger it. Right now you have to go to Plugins --> Life360 --> Create Quick Geofence
Open to ideas about how to make it more Indigo Touch friendly. If it's an Action, I'll need some tips as to how to prompt the user in real time for a device / member.

About:
v2023.1.4 introduces a Beta Dynamic Geofence Feature with can be access from the Plugin menu

How to use:
- upgrade the plugin as usual
- Go to plugins -> Life360 -> Create Quick Geofence
- Choose the Life360 Member
- Press Execute

This will create a new Geofence called Life360 temp geofence - using:
- the lat and long where the member is currently
- a radius hard coded to '0.0762' - This will be moved to the Plugin Preferences at some point
- the folder DEVICES - This will be added to Plugin Preferences at some point

Posted on
Sun Dec 31, 2023 11:52 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Life360: Feature Request: Temp Geofence

For right now, I suggest creating a few action groups for your control pages. 1 for each person. I'm not sure how to make it more dynamic.

Posted on
Tue Jan 02, 2024 3:18 pm
whmoorejr offline
User avatar
Posts: 763
Joined: Jan 15, 2013
Location: Houston, TX

Re: Life360: Feature Request: Temp Geofence

Zero error handling on my part, but this is what I have so far as a work-in-progress with your plugin update.

Pre-Create a 2-part action that 1. deletes a temp geofence, then 2. creates a temp geofence. duplicate this for each member of the house.
The "Delete" part will ensure that if the temp fence was already created, you will be deleting it and building a new fence with the device's current lat/long. If there wasn't a temp geofence already there, the script will throw an error, but it will move on to part 2: create a temp geofence.

For deleting:
Code: Select all
indigo.device.delete("Life360 temp geofence - Bill")


For a trigger to get a notification, these can also be set up in advance using the device (phone) as the trigger (i.e. if the closest address changes) For the condition, a script that checks to see if the device is still in the fence

Code: Select all
target = "Bill"
tempGeofence = indigo.devices["Life360 temp geofence - Bill"]
members = tempGeofence.states["members_in_geofence"]

if target in members:
   return False

else:
   return True
Untested, but looks correct to me. I'm not sure if the trigger will fire or not (is it False if the script errors out becuause the geofence doesn't exist yet)?

From this, I should be able to have one button that sets or re-sets a temp geofence per person with pre-built notifications using triggers!!!

I'd say success. I can't think of a way to make it more dynamic either. I don't think drop down lists are an indigo touch option.... and one button per device should be fine for anyone.... except maybe the Duggar family (the ones with 20 something kids)


Last thought... would it be possible to have a moving fence device? Simiar to a temp fence, but everytime the plugin polls life360 for an update, it would update the location of that fence based on the location of the device used to create the fence. (basically re-creating a temp fence with every run concurrent. Benefit: if you create a moving fence from the L360 device "Bill", no matter where I am, I would be able to see what family devices are near me (in my fence) or conversely, what devices are no longer near me. Then theoretically there could be a trigger that watches the number of member in that moving fence for a change, if a change occurs, provide a notification (i.e. pushover notice) with the list of members in the fence (Hopefully I'll recognize what or who is missing from the list)

Tile works with Life360, correct? I can also see this being helpful if you use tile on your bike, in your luggage, etc. (I personally don't use tile, I fell in the airtag hole instead) Set a temp geofence with triggers on a bike, car, luggage, etc with notification triggers or a moving geofence around yourself to let you know if you luggage, bike, etc gets away from you.

Bill
My Plugin: My People

Posted on
Tue Jan 02, 2024 3:36 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Life360: Feature Request: Temp Geofence

whoa, your moving fence just blew my mind. It would be a different type of fence I guess.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests