Skip to end of metadata
Go to start of metadata

Poll Model Overview

Polling, as the name suggests, continuously checks for data from devices. Polling is a synchronous activity and an interval can be defined to dictate how frequently a device is checked. The device that is being polled generally has security, in the form of Basic Authentication, Header Authentication, Query Key Authentication, or OAuth 2.0. LoopCloud supports all of these authentication types.

The Poll Model typically is used for devices that constantly publish data, such as:

  • Google Nest
  • Weather channels
  • Monitoring providers, such as Monnit, which enable REST/SOAP access to their sensor measurements
  • Open Charge Alliance, which provides data from charging stations via SOAP web services

Why Transform Data?

When device data is collected, its raw data is in a unique format, but this raw data cannot be processed using common approaches. After transforming the raw data into a standard format, the data can be processed automatically.

The  OMA LightweightM2M (LwM2M) Object and Resource Registry standard format is used in the Loop platform.

The main benefits of using the standard format include:

  • Process data automatically without custom algorithms, whereas collected data in its raw format would require algorithms for each group of devices.
  • Create alerts using user-defined rules. For example, if a temperature sensor should not exceed 30 degrees, when the temperature reaches 31 degrees, users can be notified by email or other ways, including webhooks, which can run another automated process.
  • Expose the data to LoopInsights, which enables the creation of relevant dashboards.
  • Display a richer set of object values in the LoopCloud Device Explore tab.

Create a Poll Model

To create a Poll model in LoopCloud:

  1. Click the company name at the top of the LoopCloud window.
  2. Click a Project.
  3. In the navigation panel, select Configuration > Models.
  4. Select the POLL tab. See also, Model Types.
  5. Click New Model.
  6. In the CONFIG tab:
    1. Enter a Model Name.
    2. Select a Method: Post, Get, Put, or Delete.
    3. Enter a Request URL.
    4. Select a Poll Interval.
    5. If required by the device to be polled, select Credentials.
  7. Click Test.
  8. Click Save.

This logic also can be loaded from a Web Services Description Language (WSDL) file. Go to the Open Mobile Alliance website for OMA WSDL packages.

Transform Data into OMA Format

To transform data into OMA format in LoopCloud:

  1. In the navigation panel, select Configuration > Models.
  2. Select the POLL tab.
  3. Click the model card.
  4. Click the TRANSFORMATION tab.

  5. Paste the Groovy transformation script into the Step 1 window.

    • Typically, only one step is required. However, additional steps can be added by clicking the + sign.
    • Additional steps can be used to simplify the script. For example, several steps may be added to parse a large response from a web service.

  6. Select the script type (in this case, Groovy) and click Save.

  • Click Test to validate the script.
  • Error messages are displayed at the bottom of the browser window.

Sample Transformation Script

This logic also can be loaded from a Web Services Description Language (WSDL) file. Go to the Open Mobile Alliance website for OMA WSDL packages.

The following script is for transforming OMA object 3313 (Accelerometer), Resource 5702 (X axis value). Do not modify parameters.

import com.litmusloop.common.device.Payload

 * in: byte[] input
 * in: OMNARegistry omnaRegistry
 * out: return List<Payload.Value>

def slurper = new groovy.json.JsonSlurper()
def response = slurper.parse(input)
List<Payload.Value> result = new ArrayList<>()

for (def item: response) {
    def peakRms = item.InsightTimeFrequencyData.Peak_RMS_Value
    int objectId = 3313
    String instanceId = item.Sensor_Name 
    String value = item.InsightTimeFrequencyData.Peak_RMS_Value
    int resourceId = 5702
    def meta = new HashMap<String, String>()
    meta.put("Mounted_Axix", item.Mounted_Axix)
    def accelerometer = new Payload.Value(
            omnaRegistry.getResourceItem(objectId, resourceId).get().getType(),
return result

Deploy a Device for the Poll Model

To poll the device for data, create a LoopCloud Device from the Poll Model

  1. In the navigation panel, select Configuration > Models.
  2. Click the model type at the top of the window, in this case: POLL. See Model Types.
  3. Find the Poll model and click the plus sign (+) in the model's card.

A message at the bottom of the browser indicates that the device has been added. The device now appears in the Devices list: Device Mgmt > Devices.

Web Service Example

For an example of how this Poll Model can be used to collect and transform data, see the steps in the Transformation Web Service Use Case.

Steps to transform data:

  • No labels