Bridging IoT and legacy systems with CloudEngine (2): scheduled scripts

In our first article about bridging IoT with legacy systems, we saw that CloudEngine now provides a simple and convenient way to accumulate incoming IoT data in a temporary storage structure. And then send the data as a CSV attachment when you have reached a defined number of records. We are adding as of today a new CloudEngine capability that allows you to trigger script executions based on schedules.

CRON is a program very well known to UNIX sysadmins. It let’s you execute commands on a predefined date and time, or follow a predefined cycle. We created a new “CRON” inbound trigger for CloudEngine script, which consists of 2 parts :

1. Configuration

The first thing to do is to define your schedules. This is done in the Settings tab of CloudEngine, where you will find a new “CRON” inbound type. Select it to add a new inbound endpoint configuration. As shown in the picture below, defining a new schedule consists of:

  • identifier: a unique name for your CRON schedule. It will be used as tag to your CRON inbound endpoint in your visual flow or script
  • crontab configuration: the definition of your schedule according to the well-known crontab pattern.  For example, “0 0,12 1 */2 *” defines a schedule to be executed every 12am and 12pm on the 1st day of every 2nd month. Mind that the lowest trigger interval on our platform is 5 minutes, so even a pattern such as “* * * * *” will not execute every minute, but every 5 minutes.
  • optional payload : an optional Base64 encoded string that can be used as payload for the CRON inbound endpoint
Defining schedules for CRON CloE inbound endpoints

2. Configuring the CloE inbound

To use the scheduling trigger in any of your visual flow or script on CloE, all you need is to add the new “CRON” inbound endpoint to it, just like when configuring an inbound LoRa, HTTP, or MQTT endpoint. After adding the endpoint, you need to click on it to specify the name of the identifier (as defined above) with the relevant schedule. This is added as a tag to the endpoint. Just as with any other CloE inbound endpoint, you can use OR and AND statements to combine tags (ie. schedules in our case).

CRON inbound endpoint in a CloE script

3. Combining IoT inflow and scheduled actions in one script

The script below shows how easy it is to combine into one single simple script :

  • receiving LoRaWAN data
  • storing the received sensor data in a storage structure
  • scheduling the generation of a CSV attachment out of the storage structure and sending this over mail
Storing IoT data and sending scheduled email with CSV attachment in one script

Stay tuned for upcoming blog articles on new EnCo capabilities!



Author: API Solutions Team

Biographical Info