OneNet数据推送的数据已经收到,本文提取用户关心的数据。由于水平有限,流图当中的代码不一定最优。
收到的数据,注意画红线的是我关心的数据。
?
?
?
?
?
?完整代码:
[
{
"id": "0fd09364725a5015",
"type": "tab",
"label": "流程 7",
"disabled": false,
"info": "",
"env": []
},
{
"id": "cd7cdf3bb348f91f",
"type": "http in",
"z": "0fd09364725a5015",
"name": "",
"url": "/node",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 120,
"y": 200,
"wires": [
[
"bf61b0882de84888",
"7b433526daaac6ad"
]
]
},
{
"id": "9e4f60d84798cc57",
"type": "http response",
"z": "0fd09364725a5015",
"name": "",
"statusCode": "",
"headers": {},
"x": 510,
"y": 240,
"wires": []
},
{
"id": "bf61b0882de84888",
"type": "debug",
"z": "0fd09364725a5015",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 350,
"y": 180,
"wires": []
},
{
"id": "7b433526daaac6ad",
"type": "function",
"z": "0fd09364725a5015",
"name": "",
"func": "msg.payload=msg.payload.msg\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 240,
"wires": [
[
"9e4f60d84798cc57"
]
]
},
{
"id": "568c1710900830e6",
"type": "http in",
"z": "0fd09364725a5015",
"name": "处理推送POST请求",
"url": "/node",
"method": "post",
"upload": false,
"swaggerDoc": "",
"x": 150,
"y": 340,
"wires": [
[
"1e0aad73f38f3137",
"b6cd5317107fca49",
"ee7a64e90baa01a0"
]
]
},
{
"id": "631328d69c736eef",
"type": "debug",
"z": "0fd09364725a5015",
"name": "Power数据",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 340,
"wires": []
},
{
"id": "1e0aad73f38f3137",
"type": "http response",
"z": "0fd09364725a5015",
"name": "响应状态码",
"statusCode": "200",
"headers": {},
"x": 370,
"y": 380,
"wires": []
},
{
"id": "ee7a64e90baa01a0",
"type": "function",
"z": "0fd09364725a5015",
"name": "提取msg",
"func": "msg.payload=msg.payload.msg;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 340,
"wires": [
[
"833a1f1bd58ba96b",
"cd7b28862feb2dae"
]
]
},
{
"id": "b6cd5317107fca49",
"type": "debug",
"z": "0fd09364725a5015",
"name": "原样",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 350,
"y": 300,
"wires": []
},
{
"id": "833a1f1bd58ba96b",
"type": "json",
"z": "0fd09364725a5015",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 530,
"y": 340,
"wires": [
[
"058c8bf90313ec11",
"cfba991849f79082"
]
]
},
{
"id": "058c8bf90313ec11",
"type": "function",
"z": "0fd09364725a5015",
"name": "提取Power",
"func": "var newd = msg.payload.data.params.Power;\n//var newd =msg.payload.data.params.Power.value;\nmsg.payload=newd;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 690,
"y": 340,
"wires": [
[
"631328d69c736eef"
]
]
},
{
"id": "cd7b28862feb2dae",
"type": "debug",
"z": "0fd09364725a5015",
"name": "提取1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 530,
"y": 300,
"wires": []
},
{
"id": "cfba991849f79082",
"type": "function",
"z": "0fd09364725a5015",
"name": "提取Temp",
"func": "var newd = msg.payload.data.params.temp;\nmsg.payload=newd;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 700,
"y": 380,
"wires": [
[
"86b3fa5090a534d1"
]
]
},
{
"id": "86b3fa5090a534d1",
"type": "debug",
"z": "0fd09364725a5015",
"name": "Temp数据",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 380,
"wires": []
}
]
|