Cloud Triggers

Cloud triggers provide event-driven functionality to initiate the appropriate actions in response to real-time events.  

Note:

By default, 100 triggers are allowed per second. Only Super Ops have permissions to change it.

The condition defined in an event actively monitors the real-time data and when the threshold is met as defined in the event, it causes a trigger to execute.  A trigger includes the following components:
  • cloud trigger events (trigger events or events) and event variables

  • cloud trigger actions (trigger actions or actions) and action variables

  • routes between actions

  • success and failure actions

Cloud Trigger Events

A cloud trigger event is the condition that causes a trigger to execute. The cloud trigger has access to a set of variables collectively known as trigger variables. The first set of variables available to the trigger are the event variables. Variables are event-specific.

Cloud Trigger Actions

Cloud trigger actions are the sequence of instructions that examine information (for example, math.if), acquire data (for example, property.current), manipulate values (for example, math.expr), store information (for example, thing.attr.set), and execute commands (for example, method.exec). Each action has access to the trigger variables from the preceding actions, including the event variables.

Trigger Variables

The trigger variables represent the metadata that accumulates during the execution of a trigger.  It could take the form of event variables generated when the event occurs or action variables generated when actions complete. These variables can be used as inputs to subsequent actions to enable complex manipulation of data within a trigger.

Event Variables

Event variables have the format $(event.NNN), where NNN is the specific variable name.  Event variables express the point-in-time metadata from the particular event that occurred to execute the trigger.  Event variables include data that is current as of the execution of the trigger. For more information about events and event variables, see Cloud Trigger Events.

Action Variables

Action variables have the format $(action.X.NNN), where X is the number representing the action that is the source of the variable (starting with zero) and NNN is the specific variable name. For more information about actions and action variables, see Cloud Trigger Actions.  Actions that query data from a thing query the data stored in the database, and newly published data may not be available if it was published within the same trigger.

Formatting Variables

When specifying a variable, you can use a format syntax to render the value in a special way, for example, to restrict the number of decimal places.  To use this feature, when specifying a variable, you can add a colon (:) to the format string.  For example, if you query the current value of a property, it outputs $(action.0.value) to represent the current value of a particular property.  You can specify $(action.0.value:%.2f) to limit the precision of the property value to two decimal places.

The following shows the supported formats:

Format

Data type

Description

%d

Integer

base ten

%o

Integer

base eight

%x

Integer

base 16 (lower case)

%X

Integer

base 16 (upper case)

%f

Float

decimal point notation (123.45)

%e

Float

exponent notation

%U

String

escape HTML

%ms

String

to retain milliseconds

By default, milliseconds are truncated

For floating point values, the following table shows the supported precision values:

Format

Description

%f

default width, default precision

%9f

width nine, default precision

%.2f

default width, precision two

%9.2f

width nine, precision two

%9.

width nine, precision zero

Routes

Triggers allow different routing to occur based on binary success and failure paths, as well as through decision actions (such as math.if). This allows a single trigger to make decisions based on information it has acquired and execute different actions based on the result of the decision action. The next action executed, based on the result of the current action, is called the route. The event has a single route leading to the first action to execute. Most actions only have the option for a success and a failure route. Some actions have options for failure, true, and false routes.

Success and Failure Actions

Although it is common for failure routes to lead to a failure action, it is possible that an action may fail to execute and the failure route leads to a corrective or an acceptable alternate action that can cause the trigger to terminate on a success action.

Data published to things may take time to become available in the database if multiple values are published at the same time. For example, calling a property.change event on property #1, and then reading the current value of property #2 may return an old property value if it has not yet been stored in the database.

Trigger Reports

Trigger reports contain the events that have been executed with exact time, period, and status of execution. You can enable or disable the trigger reporting and specify whether to generate a report each time a trigger executes or only when the trigger execution fails.