New Rule Engine

Introduction

With the New Rule Engine you can create rules for your IoT devices, which enable you to receive notifications via email or SMS, as well as trigger downlinks and control third-party systems through webhooks when defined conditions are achieved.

One single rule allows you to monitor up to 1000 devices, receive notifications when devices go offline and online, as well as define time windows for receiving notifications and triggering downlinks, ensuring efficient and resource-saving operations.

Quick Start Guides

We have prepared some guides for you to help you set up rules for specific scenarios.

Online Status Notification

Message Counter

E-Mail Reporter

Now it's time to provide a detailed guide that will walk you through the steps required to set up rules.

Overview

Choose Product

As the first step in setting up the rule, you need to select the product on which the rule should be created.

To do this, you need to know that every device on Datacake belongs to a product. A product can have one or more devices, and the definition for the dashboard, decoder, and database fields are at the product level.

All devices in the product have the same settings but can store data individually. Configuration fields also lie in the product definition and allow for a default value that can be overridden at the device level. These can also be used in the rule, but more on that later.

Why is this important?

As mentioned, rules are defined at the product level. This has the advantage that I only have to create one rule for a fleet of several hundred devices instead of creating a separate rule for each device. This has enormous advantages in scalability.

Once selected the product you are able to choose if you want to setup the rule to "Excecute rule for all devices of this product" or if you want to "Excecute rule only for selected devices of this product", which allows you to filter devices on a product with a specific tag.

Press on "Show Devices" to see a list of the devices that will be taken into consideration at the moment of configuring the rule.

Match at least one tag

Here the rule is executed for those devices that have at least one of the defined tags.

Match all tags

Here the rule is only executed for those devices that have all the defined tags at the same time.

Select Triggers

Once the product and grouping are selected, you can now choose the trigger that defines how and when the rule is executed.

New Measurement

The rule's defined condition gets reviewed when a device receives a new measurement.

Device goes Offline

When the defined online timeout gets exceeded, the rule gets triggered.

Device goes Online

If the device has been offline and then it comes back online the rule gets triggered.

Timebased Schedule

When you select the timebased schedule you get the option to configure a rule to be evaluated using the following settings:

At a specific time

You select the exact time at which the rule should be triggered. For example, if you want to send an email every morning at 8:00 am with the measurements from your devices.

Interval between times

The condition setup will be reviewed only with the values coming between the defined window of time.

Custom crontab expression

You can setup the custom crontab expression, which enables you to setup a very personalised Timeframe in which your rules should be reviewed. You can create your own crontab expressions using the following reference:

You can as well use the following characters to setup the expressions:

  • "*" -> Any value

  • "," -> Value list separator

  • "-" -> Range of values

  • "/" -> Step values

So if for example, you would like to setup a time-based schedule that reviews the rule at 00:00 on day-of-month 1 and 15, your crontab expression would look like 0 0 1,15 * * .

Or, for example, your rule should be reviewed at 22:00 on every day-of-week from Monday through Friday, your crontab expression would look like 0 22 * * 1-5.

In the following video you will learn how to use the different options for time-based schedules on the new rule engine.

Define Conditions

Conditions are optional! For your information in advance: it is not mandatory to define conditions. No conditions are required for triggers such as Online, Offline, and Timebased Schedule.

Attention: if you have chosen New Measurement as a trigger, you should also define a condition in addition, otherwise the rule will always be executed when new measurements are stored in any of the devices belonging to the product.

When you add a new condition, a detail view opens on the right side of the screen. This is where you can set up the condition.

Description

You can optionally enter a description here, or leave it empty so Datacake can autogenerate it for you.

Measurement Field

This is where you can select the fields that are defined in the product (and are therefore also present on the devices you want to monitor).

Timerange Operation

The next step is to select the operation that will be used to analyse the data of the field. The following options are available.

Current

This is the measurement value as it was last written to the field. It is the current measured value.

Average

When you select this option, another field opens where you can define a time range that will be used to load the data as a time average from the database when evaluating.

Min

Also like Average only this option returns the minimum value for the defined time range.

Max

Here it is the maximum value over defined time range.

Relative Change

Relative Change returns the change over the defined time range. Here two measured values are loaded, once for the start of the time range and once for the end of the range. Then a delta is formed, the change, which is then used for the evaluation of the rule.

Absolute Change

Like Relative Change, except that the change is not absolute but a percentage change over the time range.

Sum

Using Sum, all measured values that lie within the defined time range are added up and used as a source for the rule.

Count

This returns the number of measurement points in the selected time range. This can be used to register abnormalities in the transmission behaviour or also for counting events.

Operation

This field allows you to select what type of action to be taken to activate the rule. Following options are available:

  • Equals

  • Equals not

  • Less than

  • Less than or equal

  • Greater than

  • Greater than or equal

  • Inside range

  • Outside range

Compare To

Once you have selected the operation you can select which type of values will be compared. Following options are available:

  • Constant Number Value: Once this selected next thing is to set the constant number to be used. If you select Constant Number value last thing to do is to setup a hysteresis.

  • Measurement field from triggering device: You will have to select the desired field.

  • Configuration field from triggering device: You will have to select the configuration field.

  • Measurement field from another device: You will have to select the device, as well as the field to be used.

Guides

Online Status Notification

To create an online status notification of your devices follow the next steps:

  1. Create a New Rule:

  • On the Rule Engine click on +Add Rule on the right side of the screen.

  1. Set Rule Criteria:

    • Rule Name: Give your rule a name, e.g., "Device Online Status". This field is obligatory.

    • Timezone: Set the timezone your rule should consider. If you create a time-based schedule this field is important. Otherwise the rule engine will take UTC as the default timezone.

    • Branding: Choose the branding. If you have a white label site, you will see it as an option on the drop-down-list. If you don't, default will be Datacake's branding.

  2. Choose a Product:

Select the product that your triggering devices belong to.

  • Execute rule for all devices of this product: The rule will take ALL devices on that workspace belonging to the previously selected product.

  • Execute rule only for selected devices of this product: The rule will take only the devices with a specific tag or multiple tags selected on this step.

Rules work on a product level, which means that you need to create one rule per product.

  1. Select the Trigger:

As trigger you will select "Device Goes Offline" and/or "Device goes Online".

Selecting the "Device Goes Offline" trigger will enable you to receive notifications when any device associated with the defined product loses its connection (see Online timeout). On the other hand, the "Device Goes Online" trigger ensures that you are alerted when previously offline devices re-establish their connection.

It's important to approach this feature with caution. For instance, if you have 50 devices linked to the product and 10 of them go offline, the system will dispatch individual notifications for each device. This means in such a scenario, you'd receive 10 separate notifications. So, be prepared to manage the volume of alerts accordingly.

  1. Define the Actions:

    • Upon meeting the condition, you'd want the rule to perform an action. This is where you specify what the action is.

    • Choose "E-Mail" or "SMS" to send a text notifications. If you select "SMS" make sure you have enough credits on the Billing section.

    • Select your receivers: In case of an E-Mail notification, setup the email addresses of your receivers. For SMS notifications, setup the phone numbers of your receivers.

    • Craft your notification message: Draft the content of your message. Ensure it's clear. For example: "Alert! Device {{ triggering_device["name"] }} has gone offline." Start typing "triggering_device..." to get a bunch of suggested fields you can add to your notification as well.

Now your Offline/Online notification is setup and ready to use!

Message Counter

E-Mail Reporter

Last updated