Custom Logic
Evaluate rule logic with a JavaScript script.
A Custom Logic block runs a JavaScript script each time a rule is triggered. Use it for logic that a comparison cannot express. Scripts can be stateless, or keep a state between runs.
Custom logic blocks are created at organization level. They are available in all workspaces and can be selected when you create a rule.
A custom logic block consists of:
The device data the script evaluates, such as a sensor value.
Constant values, such as thresholds, set when the block is used in a rule.
The logic that runs and emits actions.
Inputs
Inputs define the data sources of the block. They hold the dynamic data of a device. A block needs at least one input.
Display name
The name of the input.
Description
An optional description.
Variable name
The name used to access the value in the script, as event.inputs.<name>.
Default topic
An optional topic that is preselected when the block is used.
Default data key
An optional data key that is preselected when the block is used.
Parameters
Parameters are static values available while the script runs.
Display name
The name of the parameter.
Variable name
The name used to access the value in the script, as event.properties.<name>.
Type
Numerical, String, or Boolean.
Default value
The value used unless the rule sets another one.
Script
Logic Block ScriptingExamples
The example repository contains ready-made logic blocks:
This webinar shows how to create a custom rule:
Last updated
Was this helpful?