Getting started with Labeeb IoT Business Rules Engine
Labeeb IoT Platform has an integrated Rules Engine,which gives the ability to create and apply specific rules to the incoming data sent by any connected IoT devices.
The rules built using Drools a Production Rule System that uses the rule-based approach to implement and Expert System. Expert Systems are knowledge-based systems that use knowledge representation to process acquired knowledge into a knowledge base that can be used for reasoning.
What is a Rule ?
Rules are pieces of knowledge often expressed as, "When some conditions occur, then do some tasks." , Rule Structure is :
Conditions in Rules
A rule can contain many conditions and patterns such as:
- Data(temp== 35)
- Device(name == “Station1”)
The above conditions check if the Data temp is 35 or the Device name is “Station1”.
Variables in Rules
A variable name in Drools starts with a Dollar($) symbol.
- $data:DeviceData ( )
$data is the variable for DeviceData() class
Rules can work with all the native Java types and even Enum.
Hello World Scenario
The following example shows how to output "Hello World" when message received to Labeeb IoT platform :
Threshold Alert Scenario
The following example shows how to send an SMS to a specific mobile number when Humidity data received by Labeeb IoT reaches a specific threshold:
Labeeb IoT Rules Engine Capabilities :
In addition to what can be done with rule engine, Labeeb IoT platform give you multiply special Rules and Actions such like sending an email or SMS, push data to another Mqtt broker,etc ..
JDBC Update Rule:
JDBC update rule can be used to update records in a table using JDBC application, the following example shows how to update the JDBC when a message is received:
Cassandra Update Rule:
Cassandra update rule can be used to update records in Cassandra table , the following example shows how to update when a message is received:
Device Data Rule:
Device data rule gives you the ability to insert data to a specific device in Labeeb IoT platform when a new message is revived, using this rule, you can filter messages or make some modification on the data before assigning it to a specific device:
SMS Rule :
SMS rule can be used to send SMS message, it can be used as a notification for some events, or as warning, for example when received message contain temperature data type with value grater that 45 , send SMS message to a specific number :
REST rule give Labeeb IoT platform a great ability to extent and connect your data to external data bases, or trigger some actions on other platforms using REST API calls, depending on the message received by labeeb, you can decide which REST to call, for example :
MQTT Publishing Rule:
MQTT in one of the most popular IoT communication protocol and Labeeb IoT supports pushing data through MQTT, but you are not limited to that, using this rule you can redirect received messages to another MQTT broker :
generating RSS using this rule give the ability of delivering regularly changing web content. Many news-related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it.the following example shows how to use this rule: