Message Rules can be used to filter incoming data by using various type of conditions. There are two types of rules:
- Message content rules
- Device filters
Message Content Rules
Message content rules allow the users to filter the data based on the content of the message.
Adding a Message Content Rule
To add a new rule, users have to click on New content rule. In the pop-up window, they have to fill in the name of the field and then choose which message content rule option they want to use (see below). It is possible to use more than one option in one rule (e.g. combine Requirement and Type of data). Once they have the condition ready, users have to click on Add to save the rule and close the pop-up window.
As the last step, users have to click on Apply to save the changes to the receiver.
Loading rules from a file
It is also possible to load the fields from a sample JSON or XML file. The rules will be created according to the structure of the file. Each field from the file will be marked as Required and the Data type will be selected according to the provided sample value.
Example:
Create a file with this content:
{"sensorId":"F4-B8-5E-3D-92-91","humidity":45}
Alternatively, download the JSON example or XML example.
Following rules will be created:
Field name | Data type | Required | Validation expression |
---|---|---|---|
sensorId | STRING | ||
humidity | INTEGER |
Removing a Content Rule
To remove a content rule, users have to click on the icon .
To finish the operation, users have to click on Apply to save the changes to the receiver.
Message Content Rule Options
Users can use three different types of conditions:
- Requirement
- Type of data
- Validation Expression
Requirement
By enabling this condition, users can check whether the chosen field name is present in the input data. If not, the data won't be processed. Please note that this rule will be triggered only in cases when the whole field is missing. In a situation where the field is present but the value is empty, the rule won't be triggered.
Type of Data
Users can select which type of data is allowed for the chosen field. For example, they can select that only numerical (Integer) values are valid.
- STRING
- BOOLEAN
- INTEGER
- DOUBLE
- ARRAY
- OBJECT
Validation Expression
Validation expression allows the users to use a standard regular expression (Regexp) to validate the format of the field. If the value does not match the expression, the data won't be processed. You can find examples of valid regular expressions below:
Regular expression | Valid values |
---|---|
^[0-9]{1,5}$ | Numbers between 0 and 99999 |
^-[0-9]*$ | Negative counting numbers |
Device Filters
When used, data only from devices on this list will be processed by the receiver. The device has to be specified by its Device ID. It possible to add more than one device ID. Users can also remove already added device IDs.
Adding a Device to the Filter
First, the users have to click on New device filter. Next, they have to fill in the Device ID and click on Add.
To finish the operation, users have to click on Apply to save the changes to the receiver.
Removing a Device from the Filter
To remove the device, users have to click on the icon .
To finish the operation, users have to click on Apply to save the changes to the receiver.