Last updated
Last updated
Alongside user-defined inputs and parameters for Custom Device Types and Custom Logic Blocks, the implicit event property called state is provided. Using the state allows users to persist and share data ("memory") between different uplinks (state per device) and rule executions (state per rule). This can be achieved by emitting the state which will be accessible in the next invocation. The state property is shared between uplinks of the same device or for the rule engine for runs of the same rule, regardless of the source that triggered a rule execution.
Accessing the rule state property from a Custom Device Type or Custom Logic Block script:
Initially event.state property is an empty object!
An example of updating a rule state property from Custom Logic Block script:
or
An example of a Custom Logic Block script that makes use of the state property:
The rule state will be reset on rule deactivation or deletion. Once a rule is activated again, the rule state property will be set to a default value.
A more advanced example of using rule state:
Refer to for all available properties.
Sharing data between uplink decodings or rule executions