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

In easy mode, you can define new rules using JSON format. First, you must define 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.
  • EVENT: The rules engine will evaluate event rules when remote devices send event messages to the OpenGate platform.

Configure datastream and parameters in rule

Datastreams and parameters value 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.

Spec