curl --location --request POST 'https://test.your-api-server.com/api/connection/task' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Calculo_Temperatura_Promedio",
"type": "formula",
"connection": "507f1f77bcf86cd799439011",
"scope": "write",
"constants": [
{
"name": "FACTOR_CONVERSION",
"value": "1.8"
},
{
"name": "OFFSET",
"value": "32"
}
],
"operations": [
{
"name": "Promedio_Celsius",
"alias": "temp_promedio_c",
"formula": [
{
"classification": "variable",
"value": "temp_sensor_1"
},
{
"classification": "operator",
"value": "+"
},
{
"classification": "variable",
"value": "temp_sensor_2"
},
{
"classification": "operator",
"value": "/"
},
{
"classification": "constant",
"value": "2"
}
],
"connection": "507f1f77bcf86cd799439011"
},
{
"name": "Conversion_Fahrenheit",
"alias": "temp_promedio_f",
"formula": [
{
"classification": "variable",
"value": "temp_promedio_c"
},
{
"classification": "operator",
"value": "*"
},
{
"classification": "constant",
"value": "FACTOR_CONVERSION"
},
{
"classification": "operator",
"value": "+"
},
{
"classification": "constant",
"value": "OFFSET"
}
],
"connection": "507f1f77bcf86cd799439011"
}
],
"emitChange": true,
"topic": "miobox/tasks/temperature",
"pollRate": 5000,
"pollRateType": "ms"
}'{
"message": "Tarea creada exitosamente",
"task": {
"_id": "507f1f77bcf86cd799439012",
"name": "Tarea_Calculo_Temperatura",
"type": "automation",
"connection": "507f1f77bcf86cd799439011",
"mode": "continuous",
"scope": "read",
"tag": "DB1.DBD100",
"constants": [
{
"name": "PI",
"value": "3.14159"
}
],
"operations": [
{
"name": "CalcularTemperaturaPromedio",
"alias": "temp_promedio",
"formula": [
{
"classification": "variable",
"value": "temp_sensor_1"
},
{
"classification": "operator",
"value": "+"
},
{
"classification": "variable",
"value": "temp_sensor_2"
},
{
"classification": "operator",
"value": "/"
},
{
"classification": "constant",
"value": "2"
}
],
"connection": "507f1f77bcf86cd799439011"
}
],
"emitChange": false,
"topic": "miobox/tasks/temperature",
"unitId": "1",
"fc": "3",
"address": "40001",
"quantity": 10,
"pollRate": 1000,
"pollRateType": "ms",
"delay": false,
"deleted": false,
"createdAt": "2019-08-24T14:15:22.123Z",
"updatedAt": "2019-08-24T14:15:22.123Z"
}
}