Rule Engine

Introduction

Rules allow you to act on events caused by a device's measurements. They allow you to set different triggers and alarms, such as:

  • Send notification messages via email or sms

  • Call external services via webhooks

  • Send downlinks to LoRa devices

  • and much more

Getting started

Rules can be created and accessed from the workspace's sidebar menu. Rules that are related to a device (one or more conditions reference the device) are additionally shown in the device's Rules tab.

Create your first rule by clicking the "Add Rule" button in the top right.

An empty rule

Here you can set a name for the rule and add one or more conditions and actions. Choose a device and field from the first dropdown and then select the condition. In the following case, I want the rule to trigger when the value of the field Testfield on the API Test device falls below 20:

A simple condition

Choosing a time range

A rule can check the current value of a field or alternatively the sum or average over a specified timeframe. The timeframe can be chosen using natural language.

This condition evaluates the average of the field

Using hysteresis

Setting a hysteresis allows you to handle values that jump around a threshold. Imagine a temperature sensor that isn't so accurate and outputs a series of values like 19.9ÂșC, 20.1ÂșC, 19.8ÂșC, 20.2ÂșC. Setting the condition to "larger than 20ÂșC" would cause the rule to trigger two times in the above series. Setting a hysteresis of 1ÂșC would require the value to drop below 20-1 = 19ÂșC before the rule can trigger again.

The following chart further visualises the function of a hysteresis:

Actions

Email

The email action allows you to send an email to one or more recipients. You can set the subject as well as a rich formatted message. Using "Insert Placeholder" you can also insert measurements from your devices.

SMS

Similar to the email action, the SMS action allows you to send text messages to one or more recipients. Please note that your workspace needs to have SMS credits which can be purchased in the workspace's billing section.

Webhook

External systems that support incoming webhooks can be notified by using the webhook action. You can set an URL, custom headers as well as a custom body that can contain placeholders.

You can send predefined downlink messages to your LoRa devices using this action.

Execute D Zero OS function

If you own a Datacake Industrial Gateway, you can use this action to execute functions on the device.

Limiting the execution

Retriggering

By default, the rule is only triggered once after a condition becomes true. It is only triggered again once the condition becomes false and true again (see the hysteresis section above). You can change this by activating the "Allow retriggering" option.

Rate limiting

You can set a number of seconds that have to pass before the subsequent execution of a rule.