For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

Part
What it is

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 and parameters cannot be edited while the block is used in an active rule.

Inputs

Inputs define the data sources of the block. They hold the dynamic data of a device. A block needs at least one input.

Field
Description

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.

Field
Description

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 Scripting

Examples

The example repository contains ready-made logic blocks:

This webinar shows how to create a custom rule:

Webinar about how to create custom rules

Last updated

Was this helpful?