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

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

How to setup:

1. Rendezvous plugin

Login to Site Admin (Legacy)> Plugins > Get More Plugins, Download and install the Rendezvous plugin.

2. Custom variable

Add a custom variable with the name of your choice (see Custom-Variables for how to add a custom variable). In this example, the variable is named AttachedTo.

Screenshot 2024-10-24 at 12.13.28.png

3. Custom variable in the asset list

Add the custom variable to the asset list, please go to Manage-columns-add-variables-in-the-assets-panel for more information on how to do that.

4. Event rule

  1. Create a new event rule

    • name it accordingly
    • set which tags it shall be applied to
    • set when the rule shall be active

  2. Under Expressions, add a Script Expression (make sure to have the privilege _EditScriptExpression. activated, please follow this guide if it is not visible) 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);
    context.setState(st);
    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);
    }
    context.setState(st);
    return false;
    }
  3. Under Notifications, configure as seen in the screenshot

    mceclip1.png
  4. Save

5. Result

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

Screenshot 2024-10-24 at 12.17.50.png