Fuel Theft Alarm
GpsGate Server can help you to detect possible fuel theft, loss or leakage by using a script in your Event Rules. You can set up alerts when a significant loss of fuel is detected in your vehicles.
- A GPS device capable of fuel level reading (check here for compatible devices by searching by the keyword fuel).
- Latest Plugins installed in the server
- Privilege _EditScriptExpression enabled in Privileges and Features of the application you want to implement this feature.
- The Fuel device signal (input) mapped to the variable Fuel level in the Device Mapper
How it works
The script saves 8 consecutive fuel level measures and calculates the mean for the first 4 values and also the mean of the last 4 values.
If the difference is larger than the threshold specified, it would indicate abnormal fuel consumption.
By default the script has a threshold of 3 (the difference between both means in liters). This value can be modified according to the fuel level signal inputs you receive from your device (liters/gallons). If you receive the fuel level input in voltage check this guide to convert that to liters.
- Note: These calculations rely on the values sent from the device. This method cannot assure 100% that you are actually getting fuel theft. There could be another cause for the alarm being triggered: fuel leakage, bad readings from the fuel sensor, wrong threshold value, etc. The most accurate the values you receive, the more efficient the script will be.
Create your Event Rule
In your application go to Admin > Event Rules and create a new rule.
Select your settings and in 4. Expressions select Script Expression
Then click on Edit
Paste the following script in the editor:
- Note: when using copy-paste from this blog to the script editor, make sure the characters <i> get replaced by [i]
The result should be like in the image. Notice that in the right of the screen you can add variables to test the script in case you want to introduce modifications.
In the step 5. Notifications you can add, for example, an Icon to see on screen when the script returns “True”.
To test the script, you can either test directly on the Event Rule script as shown in the image above or you can use SimOne.
When submitting Fuel Level values to your application, if the fuel consumption surpasses the threshold, you should get an alert as shown in the picture:
You can combine this Script Event with any other Expression in your rule, for example if Ignition signal is Off.
As a notification method, you might use SMS. With SMS, you'll know immediately when the event occurs.
- Note: you can add the Map Link variable to your SMS notification to know exactly where the event happened and visualize it in the map with your default map application.