HTTP Action

Overview

HTTP actions are another class of action that can be programmed for any trigger.

The CloudPlugs HTTP(S) action template allows to use the following methods:

  • GET. Requests data from a specified resource.
  • POST. Submits data to be processed to a specified resource.
  • PUT. Uploads a representation of the specified URI.
  • DELETE. Deletes the specified resource.

The template supports multiple Special Symbols (special text strings) that can be used to provide information gathered by the system.

Note:

The text in the Body of the request must be within quotes (e.g. "msg: Hello"). Otherwise, any Special symbols used will be ignored.

Here is a sample template. The next section provides a full example on how to program and use an HTTP action.

New HTTP Trigger

Example

Here is an example of how to create a Threshold Trigger that will automatically create a POST HTTP action when a device exceeds a temperature threshold, and will send an email when the temperature crosses below the threshold. Note that if the first data point is below or above the threshold, the corresponding action will be triggered. After the first data point is published, actions will be triggered only when the threshold is crossed.. The trigger will use a channel called temperature.

NOTE: For security reasons, parameters such as the URL have been changed from the values used for the test.

1. Create a Threshold Trigger and set the Threshold value to 40. threshold 40
2. Create and save a HTTP action called HTTP Request when the data value exceeds the threshold. The action will use a POST method to send data that will be available on a posted.txt file. New HTTP Action
3. Create and save an Email action called Temp OK email when the data value goes below the threshold. email action
4. Save the trigger and then save the device. Save triggerSave device
5. Publish 30 on channel temperature. Publish 30
6. Verify that the Boiler temp ok at 30 ºC email is received since the value is below the threshold. email Below
7. Publish 45 on test/temp. Publish 100
8. Verify that the data posted has been correctly processed by the server by checking the contents of the posted.txt file. HTTP Post
Still need help? Get in touch!
Last updated on 6th May 2021