This tutorial will show how to create a trigger in Carriots. We suppose you know the basics of working in Carriots. If you are a newcomer you might want to visit the Get started with Carriots tutorial and Carriots entities documentation page.
The Carriots hierarchy is "project" → "service" → "group" → "device", and a trigger must be associated to a service. Each data received by a device of that service will launch the trigger to push the data.
To set the trigger, is necessary to specify the URL, parameters and headers, if needed.
- Name, for easy location
- Max retries: when Carriots push data, it is possible that the counter part is unreachable. This field defines the maximum number of retries for pushing a single data
- Push frequency: define the number of minutes that Carriots will wait before pushing the data. 0 is for enqueuing the data immediately
- Id service: is mandatory to associate devices below
External configuration is the main HTTP configuration:
- URL (mandatory), for example http://api.othersystem.com/listenservice
- Verb: GET, POST, PUT or DELETE
- Http auth: if you need provide a username and password when you make a request
- Payload: Only for POST and PUT methods. Its sent in the body of the request
- Be sure to have your trigger enabled if you want it to be executed
In this tutorial we will follow a simple example:
Suppose that we are receiving two data in Carriots: "temperature" and "humidity".
The data stream will contain the following information:
We want to push the "temperature" to another external service (http://api.othersystem.com/listenservice) when receiving the data.
To create a trigger go to the control panel, then to “Rules” → “Trigger (Push)”. Then click on the new button.
When Carriots receives a data stream it will fire the trigger.
Fill the fields and save the new trigger
- Name: The name that you prefer
- Description: The description that you prefer
- Max retries: 2
- Push frequency: 5
- Enabled: Checked
- Id service: The Id_service that you prefer
- URL: http://api.othersystem.com/listenservice
- Verb: POSt
- User: Leave empty
- Password: Leave empty
- Payload: Temp=%%%temperature%%%
Note that you must type the "data name" like "%%%name%%%" to access the value. This way you can build the "payload" as you like.
- Create a trigger
To test your trigger you only need to send a data stream to a device of the associated service and you will receive it in the defined URL.