Hi all,
I just started playing with Automagic a few days ago and I wanted to turn an old android phone into a tracking and Geofence device similar to the LoJack Early Warning system. The idea is to text a command to my phone to have it "mark" the current location and set up a 20 meter perimeter and alert me if the car exits the perimeter.
I know there is the Periodic Location Update trigger, but I'm not sure how to make it dynamically update the location whenever I send the command. It seems that this trigger only works with predefined locations. I also tried the Init Location action but I'm not sure how to incorporate this into the various Location triggers.
Thanks in advance!
Help with "dynamic" Geofence
Moderator: Martin
Re: Help with "dynamic" Geofence
Hi,
There is no built-in action to trigger on dynamic geofences. Creating such a feature requires some scripting functions.
In a first flow, create a dynamic location and assign the location to a global variable:
-trigger SMS Received: All containing newLocation(
-action Script: global_loc = eval(sms_text)
You can send an SMS to your phone with the text newLocation(46.1234,7.5678). The text is evaluated in the script action which creates a location object and assigns the location object to the global variable global_loc.
A second flow can check whether you are near this location:
-trigger Periodic Location Update: every 5m
-action Script: distance_to_location = distance(location, global_loc)
-condition Expression: distance_to_location < 1000
--> true: -action near location
The script calculates the distance between the current location and the location stored in global_loc (in meters).
The action in the true-branch is executed when the distance of the two locations is below 1000m.
Regards,
Martin
There is no built-in action to trigger on dynamic geofences. Creating such a feature requires some scripting functions.
In a first flow, create a dynamic location and assign the location to a global variable:
-trigger SMS Received: All containing newLocation(
-action Script: global_loc = eval(sms_text)
You can send an SMS to your phone with the text newLocation(46.1234,7.5678). The text is evaluated in the script action which creates a location object and assigns the location object to the global variable global_loc.
A second flow can check whether you are near this location:
-trigger Periodic Location Update: every 5m
-action Script: distance_to_location = distance(location, global_loc)
-condition Expression: distance_to_location < 1000
--> true: -action near location
The script calculates the distance between the current location and the location stored in global_loc (in meters).
The action in the true-branch is executed when the distance of the two locations is below 1000m.
Regards,
Martin