NodeRed 搭建web服务器--④提取OneNet数据推送的数据

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": []
    }
]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

armcsdn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值