Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

webhookWebhooks, often referred to as an HTTP callbackcallbacks, enables enable LoopCloud to push data to web applications. Webhooks are asynchronous , with a triggered event and a response. Similar to a Poll model, which pulls and have triggered events and responses. As with Poll models, which retrieve data from external web services, a webhook can be used to get you can use Webhooks to retrieve data from an external systems system and then push the that data to the Loop platform.  The webhook creates Webhooks create a web service (HTTP endpoint) that allows you to push data to be pushed to LoopCloud or a third-party systemssystem.

Webhook Use Cases

In addition to MQTT and LwM2M, LoopCloud suports supports incoming webhooks as a mechanism for receiving data from an external systemsystems.

  • Incoming webhooks are essentially basically REST endpoints.
  • Transformation rules can transform convert incoming data to a format supported by the Loop platform. See Webhook Model Transformation.

Example Webhook Case

SigFox serves acts as an IoT sensor network and it allows users to define a webhook that will be called on each change of a Webhooks to invoke upon each sensor metric change. See SigFox Transformation Example.

Create a Webhook Model

To create a webhook model in Webhook Model with LoopCloud:

  1. Click the company Company name at the top of the LoopCloud window.
  2. Click the Project.
  3. In the navigation panel, select choose Configuration > Models.
  4. Select the WEBHOOK tab. See also, Model Types.
  5. Click New Model.



  6. In the CONFIG tab:
    1. Enter a Model Name.
    2. Notice that the Access Token field gets populated automatically.
  7. Click Save.
Info

Once When you deploy a device is deployed from a webhook Webhook model, the webhook Webhook will be available as a URL , in the following format: https://litmus.pro/webhook/{projectId}/{deviceId

...

SigFox Transformation Example
Anchor
SigFox Transformation Example
SigFox Transformation Example

Define You can define transformation rules, which transform incoming data to the as shown in the following example. The following rules convert incoming data into a format supported by the Loop platform, as illustrated in the following example.

No Format
Code Block
languagejs
themeDJango
linenumberstrue
import com.litmusloop.common.device.Payload;
import groovy.json.JsonSlurper;
import org.apache.commons.io.IOUtils;

/**
 * in: byte[] input
 * in: OMNARegistry omnaRegistry
 * out: return List<Payload.Value>
 */
String inputJson = new String(input);

def jsonSlurper = new JsonSlurper();
def json = jsonSlurper.parseText(inputJson);

List<Payload.Value> result = new ArrayList<>();
if (json != null) {
    // sensor id
    String sensorID = json.device
    result.add(new Payload.Value(
            3,       // Device
            sensorID,
            2,
            "String",
            sensorID,
            null
    ));
    // Timestamp
    String timestamp = json.time;
    result.add(new Payload.Value(
            3,       // Device
            sensorID,
            13,
            "Time",
            timestamp,
            null
    ));
    // RSSI Level
    String rssi = json.rssi;
    result.add(new Payload.Value(
            3305,       // Power Measurements
            sensorID,
            5800,
            "Float",
            rssi,
            null
    ));
    // Gas service inlet pressure
    String ain1 = json.ain1;
    result.add(new Payload.Value(
            3323,       // Pressure
            sensorID,
            5700,
            "Float",
            ain1,
            null
    ));
    // Voltage
    String voltage = Integer.valueOf(json.vdc) / 1000.0;
    result.add(new Payload.Value(
            3316,       // OMA Voltage ID
            sensorID,   // arbitrary instance ID = sensorID
            5700,       // OMA Sensor Value
            "Float",
            voltage,
            null
    ));
    // Meter pulse
    String din1 = json.din1;
    result.add(new Payload.Value(
            3200,       // Digital Input
            sensorID,
            5501,
            "Integer",
            din1,
            null
    ));
    // Meter pulse totalizer
    String cnt1 = json.cnt1;
    result.add(new Payload.Value(
            3200,       // Digital Input
            sensorID,
            5503,
            "Integer",
            cnt1,
            null
    ));
}
return result;