Cloud 2 Connectors

Hi,

I followed the example and created a connector on Cloud 2, but I’m not receiving any data on requestinspector. I tested the webhook using a curl command with sample data, and it worked fine.

Below is the connector I set up. Could you please check if I missed anything?

Best,
David

Dear David,
Thank you for your question. We did some analysis, and you are missing the connection with the proper tag. The tag in your connector is different than the tag in your device. Please add the tag “losant” to your device.
Another topic is triggers. You can use the “data” trigger only. Session, Config, and Shell do not contain the data you need, so you do not need to use them as triggers in this case.

Best regards,

Tomas

Thanks, Tomas. I managed to get the data after attaching the correct tag to the device.

Regarding the trigger, I need to access some information from the “session,” like the firmware version. Could you guide me on how to retrieve data from “session”?

Also, is it possible to manipulate the data similar to what we could do in Cloud v1? For instance, I used to convert the temperature from °C to °F within the callback. Is there a way to do that in Cloud v2?

Best,
David

I figured out how to perform data manipulation using JavaScript. Now, I just need help with retrieving data from the “session”.

For reference, here’s the transformation I used to convert temperature from °C to °F:

function main(job) {
  let tempC = job.message.body.thermometer.temperature;
  let tempF = (tempC * 9 / 5) + 32;
  job.message.body.thermometer.temperature = tempF;
  
  return {
    "url": "<webhook>",
    "method": "POST",
    "header": { "Content-Type": "application/json" },
    "data": {
      "thermometer": {...job.message.body.thermometer}
    }
  }
}

Could you guide me on how to access the “session” data? Thanks in advance!

Hi David,

it is planned to add this session metadata in the job object in every callback.
However, it is not implemented yet.

Right now, you can create a connector with a session trigger, which will send an HTTPS callback with a session message, but only once when the device reboots/connects to the cloud.

Another workaround could be assign this information to the device label.
You might create a python script that over API downloads latest session up message from every device and assigns the label with the same value. Then you can access the label key/valeus in the callback job object.

Thanks @tomas.svoboda for you help.