Rules

Automation rules

A rule is mainly composed of conditions and actions. This set could be defined in EASY mode, writing a JSON structure, or you could write an advanced rule writing javascript code.

Easy mode

Using the “easy mode”, you can define new rules using JSON format. First, you must specify the rule type, which will determine the structure of the rule.

  • Data stream: The rules engine will evaluate data stream rules if an entity is modified using the north OpenGate API or when OpenGate collects data through any of the south connectors. If this type is selected, you will configure the data streams the rule will use in the condition.
  • Operation: The rules engine will evaluate operation responses after being managed by the OpenGate operations engine.

Configure data stream and parameters in the rule

Data streams and parameter values can be used inside rule configuration, for example, in condition and some attributes in rule actions, following the same way:

  • datastream: $datastream:<id_datastream>
  • parameter: $parameter:<id_parameter>

Example:

  • datastream: $datastream:device.identifier._current.value
  • parameter: $parameter:threshnew

You can see more examples in schemas’ objects.

API specification