是否有可以根据输入 json 有效负载创建设备的 ant 方式。
让我们假设输入有效载荷是
{
"success": true,
"msg": [{
"deviceName": "new sensor 05",
"deviceType": "temperature sensor",
"temperature": 39,
"humidity": 76,
"serial": "ACBR342D"
}, {
"deviceName": "new sensor 06",
"deviceType": "temperature sensor",
"temperature": 39,
"humidity": 76,
"serial": "ACW4756RD"
}]
})
并打算从这个输入有效负载 Thingsboard GW 在两个设备下创建,即。根据 msg 对象中的数组数量,它应该在 thingsboard 引擎上创建该数量的设备:
- 设备 1:新传感器 05
- 设备 2:新传感器 06
和映射覆盖代码是:
"converter": {
"type": "json",
"deviceNameJsonExpression": "${msg[:3].deviceName}",
"deviceTypeJsonExpression": "${msg[:3].deviceType}",
"telemetry": [{
"key": "temp",
"type": "int",
"value": "${msg[:3].temperature}"
},
{
"key": "hum",
"type": "int",
"value": "${msg[:3].humidity}"
}
],
"attributes": [{
"key": "serialNumber",
"type": "string",
"value": "${msg[:3].serial}"
}]
}