Skip to main content Skip to footer

Data Trigger Documentation

Version: 2.2.1

Retrieved: 2025-10-09 15:15:50


Data Trigger

The module collects messages and creates an output based on a defined list of trigger definition conditions. When a trigger is fired an output message is sent. Triggers can be evaluated on momentary values or when a condition has been true for a specified time. The trigger will only be triggered again if the conditions evaluate to false and then back to true again.

Settings

Name Requirements Purpose Default
Source Property Length: 1-64 The property on the input message holding the object or array of objects with values to be used in trigger conditions data
Timestamp Property Length: 0-64 Property holding the timestamp for each object or on top level of the incoming message. If not set, the current UTC time will be used timestamp
Name Property Length: 0-64. Must be set if Value Property is set Optional. Set if the property name is a property value rather than a key to the value (see Example 2)  
Value Property Length: 0-64. Must be set if Name Property is set Optional. Set if property value is a property value on a generic value property rather than as value of the sourceProperty property (see Example 2)  
Keep Properties bool Set if properties in the message that made the trigger fire should be kept false
Convert values with best effort bool Set if best effort should be made to evaluate conditions even if the value is not according to the condition type. Boolean values of null and 0, "false" will be handled as false, 1 and "true" as true. Numeric values of null will be handled as 0 true
Trigger Definitions (Resource)   Optional. The resource that contains all trigger definitions to use. Resource and Trigger definitions path cannot both be used  
Trigger definitions path Length: 0-256 Optional. Path to trigger definitions list. If set, the module will load trigger definitions from this path on startup. Trigger Definitions (Resource) and Trigger definitions path cannot both be used  
Additional Trigger Definitions   An input table for extra triggers to monitor.  
Target Property Length: 1-64 The property on the output messages holding the information for the 'fired' triggers data

The Trigger definitions can be specified in a resource file. The resource file must contain a list of trigger definitions as defined below. In combination with this, manually added triggers can be added through the input table Additional Trigger Definitions, with the format described below. The Trigger definitions can also be stored in a JSON file locally on the node at Trigger definitions path. If set, the module will load the definitions when the flow is started. The definitions can also be updated through an input message to the module. The module will update the local file when updates are received. The trigger definitions list must be a list of objects with the following properties.

Trigger definitions

Name Type Description
id guid The id of the trigger. Must be unique within the trigger definitions list
name string The name of the trigger
isActive boolean If a trigger should send output
edge Leading, Trailing, No Edge Optional. Edge setting for when trigger is fired. Leading fires the trigger when it changes from false to true. Trailing fires the trigger when it changes from true to false. No Edge fires trigger if the trigger is true and it uses any of the properties in the incomming message
logicOperation And, Or Defines how the trigger conditions should be evaluated
conditions Condition object See below
metadata Key-value object Optional. If set, this object will be included in the output message when the corresponding trigger is fired
deleted bool Optional. If set on an update message to the module, the trigger will be removed from the internal trigger definition representation

Condition object

Name Type Description
sourceProperty string The property containing the value to evaluate
condition IsTrue, IsFalse, IsNumeric, IsNotNumeric, EqualTo, NotEqualTo, LessThan, LessThanOrEqualTo, GreaterThan, GreaterThanOrEqualTo, Contains, DoesNotContain, Startswith, Endswith, Null, NotNull, Regex, Empty Type of condition
value string, number, boolean Value to compare with. Can be a property reference with {property} syntax where property is then fetched from the message. Required if condition is a comparison type (LessThan, Contains etc.)
durationInSeconds Optional. If set: integer > 0 The time until a trigger is fired after the condition has been true. If condition evaluates to false during this period (new message) the trigger will not be fired until a new pending duration period is started when the condition is fulfilled. If not set 0 will be used making the trigger fire at once as the trigger conditions are fulfilled
secondSourceProperty string Required if arithmeticOperation is set. The property containing the value to evaluate for an arithmetic operation together with sourceProperty
arithmeticOperation Add, Subtract, Multiply, Divide Required if secondSourceProperty is set. The operation to evaluate sourceProperty and sourceProperty with

Updating Trigger definitions during flow execution

If Trigger definitions path is set and Trigger Definitions (Resource) is not set, a message can be sent to the module when the flow is running. The module will then update the internal Trigger definitions representation and store the whole set at Trigger definitions path if set. The input message must contain the property triggerDefinitions property that must be an array of trigger definitions, as described above.

Setting the deleted flag will make the module remove the flagged trigger from it's set of triggers. Any new triggers will be added and updated will replace the old one. When an existing trigger is updated, it's state will be cleared so any pending triggers will be removed and the trigger will be evaluated the first time next time a message is received that may fire the trigger.

Any error in the input message will trigger an output message with an error message for the invalid configuration. That specific trigger causing the error will not be updated or removed.

Input

The input must be an object or a list of objects. The Timestamp Property may be part of the object or each object in the list. If not, the timestamp will be taken from the top level of the incoming message. If that is not set, the current UTC time will be used. Note that if several values of a property is sent in the array, only one of the values will be used if they don't have an individual timestamp.

The latest known value of a property will be stored together with the timestamp of the object. This will be cleared on flow restart.

Output

An output will be sent when a trigger:

  • Is active
  • The evaluation of the condition changes from false to true
  • The duration (if any) is fulfilled

Format of output message:

Name Type Description
id guid The id of the trigger
name string The name of the trigger
timestamp datetime A datetime for when the trigger was fired
triggerTimestamp datetime A datetime for the timestamp for the property that caused the trigger to fire. For duration triggers this will be the timestamp for the first message received with a timestamp that caused the trigger to fire
metadata Key-value object The key-value object set in the trigger definition

Examples

Example 1 Value is set on property with a single condition

# Settings:

Source Property = data
Timestamp Property = timestamp
Name Property =
Value Property =
Keep Properties = false
Convert values with best effort = false
Trigger Definitions (Resource) =
Trigger definitions path = /data/triggerdefinitions.json
Target Property = data
Additional Trigger Definitions = []

# Data trigger definition (placed at /data/triggerdefinitions.json on the node):
[
	{
		"id": "14f84789-8bc4-487d-8363-b5dcf5320ab8",
		"name": "Trigger1",
		"isActive": true,
		"edge": "Leading",
		"logicOperation": "And",
		"conditions": [
			{
				"sourceProperty": "temperature",
				"condition": "LessThan",
				"value": 20,
				"durationInSeconds": 0
			}
		],
		"metadata": {
			"additionalNumber": 23
		}
	}
]

# Input message:
{
	"data": [
		{
			"temperature": 15,
			"timestamp": "2023-10-01T14:00:00.000Z"
		}
	]
}

# Output message:
The first element in the message will trigger an output as:
{
	"data": {
		"id": "14f84789-8bc4-487d-8363-b5dcf5320ab8",
		"name": "Trigger1",
		"timestamp": "2023-10-01T17:00:00.000Z",
		"triggerTimestamp": "2023-10-01T14:00:00.000Z",
		"metadata": {
			"additionalNumber": 23
		}
	}
}

Example 2 Value is set from template property with several conditions and duration

This example illustrates that several conditions can be combined. It gives an idea how the duration mechanism works as a condition is only fulfilled when it's value has the desired value for a certain time.

# Settings:

Source Property = data
Timestamp Property = timestamp
Name Property = name
Value Property = value
Keep Properties = false
Convert values with best effort = false
Trigger Definitions (Resource) =
Trigger definitions path = /data/triggerdefinitions.json
Additional Trigger Definitions = []
Target Property = data

# Data trigger definition (placed at /data/triggerdefinitions.json on the node):
[
	{
		"id": "14f84789-8bc4-487d-8363-b5dcf5320ab8",
		"name": "Trigger1",
		"isActive": true,
		"edge": "Leading",
		"logicOperation": "And",
		"conditions": [
			{
				"sourceProperty": "temperature",
				"condition": "LessThan",
				"value": 10,
				"durationInSeconds": 10
			},
			{
				"sourceProperty": "temperature",
				"condition": "LessThan",
				"value": "{maxValue}",
				"durationInSeconds": 0
			}
		],
		"metadata": {
			"additionalNumber": 23
		}
	}
]

# Input message:
{
	"data": [
		{
			"name": "temperature",
			"value": 15,
			"maxValue": 20,
			"timestamp": "2023-10-01T14:00:00.000Z"
		},
		{
			"name": "temperature",
			"value": 5,
			"timestamp": "2023-10-01T14:01:00.000Z"
		},
		{
			"name": "temperature",
			"value": 50,
			"timestamp": "2023-10-01T14:01:11.000Z"
		}
	]
}

# Output message:
The first element in the message will not trigger an output as all conditions are not fulfilled. The second element will neither trigger an output as the duration the condition should have been fulfilled is not reached. The third element in the message will however trigger an output as both conditions have been fulfilled the required time, although the value sent does not fulfill the conditions at that point:
{
	"data": {
		"id": "14f84789-8bc4-487d-8363-b5dcf5320ab8",
		"name": "Trigger1",
		"timestamp": "2023-10-01T17:00:00.000Z",
		"triggerTimestamp": "2023-10-01T14:01:11.000Z",
		"metadata": {
			"additionalNumber": 23
		}
	}
}