When you want to trigger an action depending on certain thresholds, use the Rules.
AllThingsTalk Platform comes with a powerful, integrated rules engine. A rules engine lets you automate work by defining actions that need to be taken in response to a set of triggers. For example, you could make it turn the lights on when you open the door, dispense cat food at predefined times, or notify you if your package is handled improperly in transport.
To define rules, no code writing experience is needed. AllThingsTalk Rules Designer is a drag and drop environment that you can use to define the logic of any complexity.
We created the video material that will guide you to see the power of Rule designer in a very short time. The video will cover the Rule creation, comparison for the water level and the related LED notification.
Since we will be using the same set of devices in examples, let’s spend a moment to get familiar with the ground devices.
- Raspberry contains a sensor named “button” (boolean) and an actuator named “LED” (boolean)
- Weather Station contains three sensors, “Temperature”, “Humidity”, and “Pressure”, all numbers
- Sprinkler contains two actuators - “Power” (boolean) and “Mode” (integer)
With that out of the way, let’s turn the attention to the ground menu. Near the bottom, you will find RULES. Click on it to access the Rules screen that contains all the rules created in the ground.
Like Devices, Pinboards, Gateways & Members, Rules are contained within a ground. This lets you use naturally separate rules belonging to different project, but also share and collaborate with other members. Read more about grounds
You will be greeted with a familiar resource creation screen. Go ahead and click on ‘NEW RULE’.
Pictured above is the AllThingsTalk Rule Designer, the drag and drop environment for creating rules. On the left, you will see the list of your devices and rule components, both of them representing pieces of functionality you can patch together to create complex behavior.
Rule components are split by their type into triggers and actions. Some of them, like devices can work as both. Triggers and actions can be recognized by icons on the right that also match the icons in TRIGGERS and ACTIONS drop areas.
Furthermore, once you start dragging a component, drop areas compatible with the component will light up.
All of rule creation comes down to connecting triggers to actions.
- When the button is pressed - notify me by email — Device is used as a trigger here, and Notify is used as an action.
- Every morning at 8 am - sound my alarm — In this case, the trigger is Day & Time, and Device is an action.