Help with "dynamic" Geofence

Post your questions and help other users.

Moderator: Martin

Post Reply
uchihashinji
Posts: 1
Joined: 10 Oct 2013 22:46

Help with "dynamic" Geofence

Post by uchihashinji » 10 Oct 2013 22:58

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!

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Help with "dynamic" Geofence

Post by Martin » 11 Oct 2013 11:30

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

Post Reply