A Guide to Rules Engines for IoT: Condition-Action Engines
What is a Condition-Action engine? And what does that look like when applied to IoT?
Join the DZone community and get the full member experience.Join For Free
What Are Condition-Action Engines?
Condition-Action-based (CA) rules engines belong to the group of Forward Chaining engines; however, there are some relevant differences, especially in the context of the IoT domain. As opposed to forward chaining engines, Condition-Action rules engines don’t allow multiple conditions, which makes them, on one hand, very limited in their logic expression capabilities and, on the other hand, much more scalable. Condition-Action rules engines (if this, then that) are sometimes extended with the ELSE statement (if this, then that — else, that).
One of the most popular examples of this type of rules engine for the IoT domain is the ifttt.com service.
Can You Build Complex Logic With Condition-Action Engines?
No, unlike forward chaining engines, CA engines cannot model any complex logic (such as combining multiple non-binary outcomes, majority voting, or conditional executions). They are meant to be used only for very simple use cases.
Can Condition-Action Engines Model the Time Dimension?
One way these engines work around the time dimension problem is that they often rely on external triggers for determining which rule to execute. That is to say, the IF condition of a rule becomes the WHEN condition (e.g. when weather is bad, send an alarm; when I come home, turn on the lights). This is often referred to as a trigger in these tools, and even though we may argue that this is not something that is part of the rules engine per se (because it needs to be coded somewhere else), it is still obvious how the time dimension could to be introduced into the rules engine.
Are Condition-Action Engines Explainable?
Just like forward chaining engines, CA engines like IFTTT provide us with an easy way of designing rules for simple problems. There is nothing easier to grasp than if-this-then-that rules!
Are Condition-Action Engines Adaptable?
Yes, Condition-Action engines are both flexible and extensible. Adding third-party API services, for example, is rather simple, as the API extensions require minimal abstractions (the 'if' and 'act' part). However, due to the nature of CA engines, there are limitations with regard to the usage of API services within rules.
Most of the times, CA engines use API services as triggered actions, not as inputs, as there is a single conditional input slot available, which in IoT use cases, is usually taken by the device data. A typical example would be, for instance, to call an external API service (SMS, email, support ticket, etc.) if a device temperature registers above 25.
When CA engines model the data of an API service as an input (what the ifttt.com CA engine, for example, calls a trigger, e.g. “if it is going to rain”), then we cannot combine this API service input with device data, as the single input slot is taken, and we can only use the device in this case as the actuator (e.g. “turn on lights”).
Are Condition-Action Engines Easy to Operate?
Applying the same rule across many devices, for example, is possible as long as thresholds and all the other conditions do not change. Templating, versioning, and searchability are rather easy to achieve with such rules engines but bulk upgrades are more difficult, as conditions and thresholds are often global variables and hard to change per instance of the running rule.
Are Condition-Action Engines Scalable?
CA rules are stateless and very simple, so it is very easy to scale these rules engines. However, they do not get the maximum score for this category, as scalability is truly achieved by only one rules engine category, namely the stream processing engines.
This is an excerpt from our latest Benchmark Report on Rules Engines used in the IoT domain. You can have a look at a summary of the results or download the full report over here.
Published at DZone with permission of Veselin Pizurica, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.