Use our rule engine code editor in a more customised way to enhance your use case with actionable information!
EARL is the rule engine within the Maker platform, in which you can make a simple rule such as if the temperature goes above X value, turn on the red LED button. But, you may probably wonder how to do a customised rule aligned with your use-case? We thought of that as well and thus, in this article we’re revealing a hidden feature of EARL and the explanation how you can use a little bit of coding and/or tweaking to create much better insights from your data.
So, let us show you a simple use-case where our imaginary fellow Bob wants to measure the corn reserves in the silos for his village. After this, the floor is yours!
Example use case: Bob’s corn level reserves
As mentioned previously, Bob is in charge to monitor the corn levels for his village, for the monthly and yearly consumption, but also to better predict the future corn plants. He came to us a bit concerned and expressed that he’d like to know the exact amount of corn in any given point of time, if possible while he’s mobile. This will assure him to know if somebody is either stealing this very precious crop and should he better prepare for the next year if it’s going to be a dry one.
We sincerely empathise with Bob and wouldn’t like that corn reserves wouldn’t be sufficient to the village. Predictive usage and maintenance are rather important in today’s information age, thus we sat down with him and created a fully functional project for the crop tank level monitoring. He stated that this solution will be of a great importance to him and the whole community in Lovinsdale!
We used off-the-shelf distance sensor on top of the tank to calculate the level of remained corn. The level of the corn remained in the silos will be checked every 10 minutes and its value will be sent and stored in our Maker platform. We told Bob that our platform comes with the intuitive visualisation and yet powerful rule engine (EARL, funny that his brother’s name is the same), which lets him automate work by defining informed actions when needed. Does that sound clear enough? If not, then we simply say: in Bob’s case, he’ll retrieve the exact corn level in a glimpse of an eye, either on his mobile phone or on the website!
Apart from the web application, we offered Bob a smartphone application to see the corn reserves when he’s mobile or outside the village, so he can react accordingly.
Custom rule creation procedure
To create a custom rule:
- Click on RULES on the left side, within the device you want to create a custom rule for,
- Hold the SHIFT key while clicking on the +NEW RULE button
- you should get the code editor such as on the image #2 above
- Paste the code like below:
tank = allthingstalk.device.DEVICE_ID_GOES_HERE / tank is the name of Device
op = allthingstalk.math.basic.op / function that performs math ops
tank.level -> op.a / level is the distance sensor
10 -> op.b / 10 is the multiplier for % value
op.a*b -> tank.fullness / tank fulness in percentage [%]
Note: your DEVICE_ID can be found at Settings (upper right corner) > Authentication
4. Name your rule and click on CREATE button to finish.
- "level" is the name of the sensor asset that measures remained corn within the silos
- "10" is the multiplier to express the remained corn in percentage
- "fullness" is the virtual asset, holding percentage value of how full is the tank
Bob is now fully aware on the corn reserves at any time as simply as that! We believe this solution will give him a good insight due to the historical data and weather predictions for the coming years.