Event rule use case: display 'connected' devices (based on proximity) in the vehicle list

There might be a scenario where two devices may be close to each other for a long period of time, for example a truck and a trailer both having their own tracking devices. And as a user, you may want to see which truck is connected to which trailer.

1. Custom variable

Add a custom variable with the name of your choice (see https://support.gpsgate.com/hc/en-us/articles/360008219474-Custom-Variables for how to add a custom variable). In this example, the variable is named AttachedTo.


2. Custom variable in vehicle list

Add the custom variable to the vehicle list, please go to https://support.gpsgate.com/hc/en-us/articles/360008876053-Manage-columns-add-variables-in-the-vehicles-panel for more information on how to do that.

3. Event rule

  1. Create a new event rule
    1. name it accordingly
    2. set which tags it shall be applied to
    3. set when the rule shall be active
  2. Under Expressions, add a Script Expression and add the following code:
    var st = context.state || { rvz_status: false, rvz_timestamp: null, rvz_name: null};
    var searchtag = 'Trailers'; //Change to the name of the tag containing the device(s) you want to look for
    var searchtagobj = session.directory.getTag(searchtag);
    var searchtagid = searchtagobj.id;
    var r = rendezvous.findAny(searchtagid,'Enter',10); //Within 10 meters
    if(r != null) {
    st.rvz_name = r.name;
    st.rvz_status = true;
    st.rvz_timestamp = new Date();
    context.setVariable("UnitName", r.name);
    return true;
    else {
    var newdate = new Date();
    var timestamp = new Date(st.rvz_timestamp);
    var time_diff = newdate.getTime() - timestamp.getTime();
    if(st.rvz_status == true && time_diff > 300000) { //In milliseconds
    st.rvz_name = null;
    st.rvz_status = false;
    st.rvz_timestamp = null;
    context.setVariable("UnitName", "");
    else {
    context.setVariable("UnitName", st.rvs_name);
    return false;
  3. Under Notifications, configure as seen in the screenshot
  4. Save

4. Result

Now when a device is close to another device and the criteria in the script matches, you will have a result like this: