How to monitor geofence status and add it into the message?

Using a plugin to detect if the position is inside a specified list of geofences and add status to the device message.

The "msg-geofence" plugin type is used to detect if the position for a given device message is inside a at least one of geofence linked to the plugin or specified in the plugin configuration. In that case it will add to the message parameters with the status (true/false) and the geofence names to the device message. 

Plugin can use geofences from two exclusive sources. You select geofences source by enabling or disabling geofences option in plugin configuration.

To use independently defined geofences that are assigned to that plugin or directly to the device you disable the geofences option in the plugin configuration. In such mode you can link to the plugin unlimited amount of geofences. This is the default and recommended mode.

To use only geofences explicitly specified in the plugin configuration you enable and define geofences option in the plugin configuration. In such mode you can define maximum 1000 geofences.

The selection of geofences source is exclusive and you can not mix geofences from both. We suggest to stick to the first mode by utilizing geofences as an individual entities on the platform and linking them to corresponding plugins and devices.

There are also two operating modes for plugin - single geofence detection or multiple. You pick operating mode by setting hit_type option.

In single operation mode the plugin adds the name of the first hit geofence into the plugin.geofence.name parameter. The plugin.geofence.status parameter is set to "true" if any geofence is hit, otherwise it will carry "false"

In multiple operation mode the plugin will store into plugin.geofence.name parameter array with names of geofences the device was according to the position information in the message.

For both plugin.geofence.name and plugin.geofence.status you can pick other parameter names that plugin will output by setting name_param and status_param configuration options.

How to use

Click on the "+" button in the Telematics Hub -> Plugins section to create a new plugin:

flespi panel telematics hub plugins

Let's define a new plugin to monitor geofence status:

flespi create geofence plugin

Then we need to assign this plugin to the right devices. Go to the Plugins tab for the required device and click the "+" button:

assign geofence plugin to device

And then you should be able to see the geofence name and status fields in the new device messages. Go to the Logs & Messages tab for the given device to check:

check messages with geofence status data

Done.

If you perform geofences detection with plugin and analyze intervals data (e.g. vehicle trips) with calculators you can use a counter of type="parameter", method="distinct" with parameter="plugin.geofence.name" to add to the interval array with names of all visited geofences during that interval (e.g. trip). This automatically will work for both single and multiple geofences detection modes.

Change log

Subscribe to the geofence plugin change log to stay in sync with any updates.

More plugin types

Find a comprehensive list of available plugin types here.


See also
Using a plugin to convert value with a stepwise linear function