How to add calculated parameters into the message?

Using plugins to add new fields into the device messages based on the expression evaluation.

The "msg-expression" plugin type is used to add a new message parameter with the value calculated in the specified expression. If the logic that you need to apply to the message parameters transformation is not that straightforward take a look into more powerful msg-pvm-code plugin.

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 that will calculate the current speed in mph and add it to the speed.mph message parameter:

add plugin of message expression type

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 plugin to flespi device

And then you should be able to see the new calculated field in the new device messages. Go to the Logs & Messages tab for the given device to check:

calculated field in device messages


Advanced note: replacing existing parameters

If you specify the name of the existing message parameter (e.g. position.altitude) as the plugin field name, the respective original message parameter will be replaced by the value from the plugin:

add plugin to replace existing parameters

Case: how to detect value change

A frequent need is to detect whether a specific parameter has changed compared to its previous value. To achieve that, you can create an msg-expression plugin that checks if a particular parameter (or set of parameters) has changed "param1 != #param1" and then adds the parameter "changed = true". After that, you can use a validate message expression "changed == true" in the item configuration.

plugin value change check

Change log

Subscribe to the expressions 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 plugins to replicate device messages.