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
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
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
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:
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.
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.
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.
If you own a Datacake Industrial Gateway, you can use this action to execute functions on the device.
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.
You can set a number of seconds that have to pass before the subsequent execution of a rule.