Access Measurements in API Decoders

Reference

Convert Serial to UUID

The measurements object, which holds the measurement data of all database fields, contains an additional level in the dictionary for API and MQTT Decoder, namely that of the device ID. The dictionary looks like this here.

measurements["26ab17ac-5ce4-41a1-b873-b2dff76a8f38"].TEMPERATURE.value

However, if you do not have the Datacake UUID available within these decoders, then you can use the following helper function in the decoder to convert a user serial to the respective Datacake UUID of your device in order to be able to identify the device in the measurements object.

var data = JSON.parse(payload.body)
var serial = data.serial // as an example

// Now request the Datacake UUID for given user-serial
var datacakeUUID = deviceSerialToId[serial]

var temperatureInDB = measurements[datacakeUUID]["TEMPERATURE"].value;

Examples

Message Counter

API Device Decoder

Last updated

Was this helpful?