Scripting with geofence group color and priority
Geofence groups can be assigned priorities and colors. Geofences display the color of the highest priority geofence they belong to. You can solve many customer requests by combining geofences, event rules, and click scripts. For more background on geofences and geofence priority, click here.
Example 1: There is a NO-ENTRY area where no vehicles should enter.
Download the sample click script. (When importing the click script XML, it will import the appropriate event rule together.)
Click here to learn how to export-import event rules.
1. First, we need to create a geofence on the access-limited area. You can use any kind of geofence to cover the area (depending on its shape). Here we are using a route geofence named: 'No Entry Route 1'.
2. Create two geofence groups:
A normal group with a priority of 100 and an alarm group with a priority of 200.
. Ensure that the geofence route created is part of the Group 'No Entry Route', as result:
3. Now we can create an 'Inside Geofence' event rule.
Here we are using a script event rule to remember the current geofence and the previous geofence.
4. Navigate to Development > App Builder > + New App
5. Create a Click Script using "Notifier" as the trigger option for the new event rule (This step has been automatically created and imported on step 1 )
6. In the click script, we will use the GEOFENCE_ID (which comes from the event rule) and check if there are any vehicles inside the geofence. If yes, then we will add the geofence to the Alarm Geofence group. Then the geofence will change to the selected Alarm Geofence color. The admin can see the geofence color directly on the application map or in the Fleet app. (This step has been automatically created and imported on step 1 )
6. When the vehicle leaves the geofence, the geofence will be removed from the alarm group and the color will back to normal.
Example 2: For the cargo unloading area, I would like to check if the area is busy. Are the trucks moving slowly or waiting in a long queue?
Using the script from Example 1, add more options to the script. You can use message.connect to load a vehicle's variables and calculate the speed, check the ignition status, etc.
Example 3: I would like to see if all of my vehicles come back to the parking area at night. I want to see this directly on the map or in the Fleet app without checking them one by one.
We can get the click script to check the number of vehicles inside the geofence. If the number is the same as the predefined number, then we will put the geofence to the "Full" group, otherwise, will show "Normal" status.
Download the sample click script and import
By using the function "geofences.getUsers" in the click script, you can get all the vehicles inside the geofence and create the logic as your business rule.