Wrong variable provided in scope

Wrong variable provided in scope

@Daniel Garcia

Hello there,

We are currently having a problem with the type of variable being provided in the scope.
We are running an analysis that only runs when the temperature variable is of certain value. The purpose of our analysis is to send out a notification to the user regarding the device and variable information. We are getting the correct device but sometimes wrong variable.
For example:

{“hwisel_user_id”:“EQVi1m”,“device_id”:“5f43e10a36cf9100276ec6d6”,“message”:“The temperature on your heater tank is below 45c for the device: Sensative Humidity Sensor (Solomon). Variable: historyseqnr, Value: 65535”,“deviceName”:“Sensative Humidity Sensor (Solomon)”}

When the correct output we get sometimes is:

{“hwisel_user_id”:“EQVi1m”,“device_id”:“5f43e10a36cf9100276ec6d6”,“message”:“The temperature on your heater tank is below 45c for the device: Sensative Humidity Sensor (Solomon). Variable: temperature, Value: 15”,“deviceName”:“Sensative Humidity Sensor (Solomon)”}

The correct variable in this case is temperature. I will provide you the code on how we are getting the variable value. Please note that the analysis should only run when the variable is temperature.

async function init(context, scope) {

if (scope[0].variable == “temperature”){
var message_string = The temperature on your heater tank is below 45c for the device: ${device_name}. Variable: ${your_variable.variable}, Value: ${your_variable.value}
….
}
}

If you can assist us on this, we would greatly appreciate it.

Thanks!
Daniel