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 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 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 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.

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 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 parameter array with names of geofences the device was according to the position information in the message.

For both 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


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="" 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
Define virtual geographic boundaries that can be flexibly linked to plugins, streams, calculators, and device groups to enable powerful location-based rules and notifications.
Explore the pros and cons of various reverse geocoding services supported by flespi.