文章目录
Node-RED开源流程网络工具
Node-RED介绍
Node-RED是一个基于Node.js的开源流程控制和网络构建工具,它提供了一个基于浏览器的流编辑器,使你可以将各种设备、API和在线服务以节点的形式拖放来构建工作流。Node-RED拥有丰富的节点库,支持多种协议转换,包括HTTP、MQTT等,非常适合用于物联网(IoT)应用的开发。
- Node-Red 是一个开源的可视化编程工具,有丰富的扩展模块可使用
- Node-Red 由IBM开发,主要用于连接连接计算机、传感器和在线服务等协议或组件,以简化它们之间的布线工作
- Node-Red 允许通过组合各部件来编写应用程序,这些部件也可以是硬件设备、Web API 、在线服务
特点和设计理念
特点和设计理念:主要特点是易于使用的可视化界面和低代码编写要求。 适合于快速原型开发和简单的数据流处理。社区活跃,提供了大量的节点(node)和功能。
Node-RDE安装
Windows安装
# 安装示例
npm install -g [email protected]
# 运行命令
运行node-red的简单方法是在命令提示符下使用命令:node-red
Docker安装
https://nodered.org/
https://nodered.org/docs/getting-started/
https://nodered.org/docs/getting-started/docker
部署命令:
docker run --network host --restart=always -v node_red_data:/data --name nodered nodered/node-red:latest
基础功能示列
HTTP发送请求
[
{
"id": "de2440cb123a1d4d",
"type": "tab",
"label": "HTTP发送请求",
"disabled": false,
"info": "",
"env": []
},
{
"id": "3207304905d4c422",
"type": "group",
"z": "de2440cb123a1d4d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"bd8c44e8e58d6faa",
"ecb1d1c7ae447621",
"dd26c20889e3cc76",
"51b65752b140f74f",
"d0dfd590b95ad100",
"ebad428a15fe28da",
"5b1c3a273ee204bd",
"0b5a4d8fa2505fd5",
"7123194f94da59fa",
"3b68291c7b5f9ecf",
"846c63bedd6a02c7"
],
"x": 74,
"y": 299,
"w": 1212,
"h": 402
},
{
"id": "68c2fee3a5c928e7",
"type": "group",
"z": "de2440cb123a1d4d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"82d9b44fb9eac18b",
"13feb548d4855386",
"eaad6b1c2086f0b4",
"85ea976f151fd9c0",
"94526b585ff89031",
"c90ccbf3b3169bd3"
],
"x": 74,
"y": 19,
"w": 1172,
"h": 142
},
{
"id": "6cb5e2a9ea5d119a",
"type": "group",
"z": "de2440cb123a1d4d",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"41613eb507de7161",
"3c921ad95542f1ee",
"70413b9103b88586",
"eae8c66f4f3ae57d"
],
"x": 74,
"y": 739,
"w": 692,
"h": 142
},
{
"id": "bd8c44e8e58d6faa",
"type": "inject",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "10",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 170,
"y": 460,
"wires": [
[
"dd26c20889e3cc76"
]
]
},
{
"id": "ecb1d1c7ae447621",
"type": "debug",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "http请求处理写文件后再发送http",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1110,
"y": 460,
"wires": []
},
{
"id": "dd26c20889e3cc76",
"type": "http request",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "http://10.81.116.13:9999/mobile-cxf/applet/test/wx7656607fe455b8ce",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "Authorization",
"keyValue": "",
"valueType": "other",
"valueValue": "Bearer 489a816a-8165-4fd0-ae8e-5a615b8549b9"
}
],
"x": 360,
"y": 460,
"wires": [
[
"ebad428a15fe28da",
"7123194f94da59fa"
]
]
},
{
"id": "51b65752b140f74f",
"type": "function",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "数据处理",
"func": "// 开始处理数据\nvar data = msg.payload ;\nvar resData = data.data;\n\n//数据转换处理\nlet obj = {\n appId: resData.miniAppId,\n appSecret: resData.miniAppSecret,\n version: resData.miniVersion\n};\n\nmsg.payload = obj;\n\n// 返回数据,继续传送数据\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 600,
"y": 460,
"wires": [
[
"5b1c3a273ee204bd",
"3b68291c7b5f9ecf"
]
]
},
{
"id": "d0dfd590b95ad100",
"type": "http request",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "http://10.81.116.13:9999/mobile-cxf/applet/sendData",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "Authorization",
"keyValue": "",
"valueType": "other",
"valueValue": "Bearer 489a816a-8165-4fd0-ae8e-5a615b8549b9"
}
],
"x": 800,
"y": 460,
"wires": [
[
"0b5a4d8fa2505fd5"
]
]
},
{
"id": "ebad428a15fe28da",
"type": "file",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "写入文件",
"filename": "D:\\\\BaiduNetdiskDownload\\\\node-red2.json",
"filenameType": "str",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "none",
"x": 480,
"y": 660,
"wires": [
[
"51b65752b140f74f"
]
]
},
{
"id": "5b1c3a273ee204bd",
"type": "file",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "写入文件",
"filename": "D:\\\\BaiduNetdiskDownload\\\\node-red2.json",
"filenameType": "str",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "none",
"x": 700,
"y": 660,
"wires": [
[
"d0dfd590b95ad100"
]
]
},
{
"id": "0b5a4d8fa2505fd5",
"type": "file",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "写入文件",
"filename": "D:\\\\BaiduNetdiskDownload\\\\node-red2.json",
"filenameType": "str",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "none",
"x": 920,
"y": 660,
"wires": [
[
"ecb1d1c7ae447621"
]
]
},
{
"id": "7123194f94da59fa",
"type": "debug",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "http请求结果-debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 570,
"y": 340,
"wires": []
},
{
"id": "3b68291c7b5f9ecf",
"type": "debug",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "http请求结果处理后数据-debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 950,
"y": 340,
"wires": []
},
{
"id": "82d9b44fb9eac18b",
"type": "inject",
"z": "de2440cb123a1d4d",
"g": "68c2fee3a5c928e7",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "10",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 170,
"y": 120,
"wires": [
[
"eaad6b1c2086f0b4"
]
]
},
{
"id": "13feb548d4855386",
"type": "debug",
"z": "de2440cb123a1d4d",
"g": "68c2fee3a5c928e7",
"name": "http请求处理后写文件",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1100,
"y": 120,
"wires": []
},
{
"id": "eaad6b1c2086f0b4",
"type": "http request",
"z": "de2440cb123a1d4d",
"g": "68c2fee3a5c928e7",
"name": "",
"method": "POST",
"ret": "bin",
"paytoqs": "ignore",
"url": "http://10.81.116.13:9999/mobile-cxf/applet/test/wx7656607fe455b8ce",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "Authorization",
"keyValue": "",
"valueType": "other",
"valueValue": "Bearer 489a816a-8165-4fd0-ae8e-5a615b8549b9"
}
],
"x": 380,
"y": 120,
"wires": [
[
"94526b585ff89031"
]
]
},
{
"id": "85ea976f151fd9c0",
"type": "file",
"z": "de2440cb123a1d4d",
"g": "68c2fee3a5c928e7",
"name": "写入文件",
"filename": "D:\\\\BaiduNetdiskDownload\\\\node-red.json",
"filenameType": "str",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "none",
"x": 860,
"y": 120,
"wires": [
[
"13feb548d4855386"
]
]
},
{
"id": "94526b585ff89031",
"type": "function",
"z": "de2440cb123a1d4d",
"g": "68c2fee3a5c928e7",
"name": "数据处理",
"func": "// 开始处理数据\nvar data = msg.payload ;\nvar resData = data.data;\n\n//数据转换处理\nlet obj = {\n appId: resData.miniAppId,\n appSecret: resData.miniAppSecret,\n version: resData.miniVersion\n};\n\nmsg.payload = obj;\n\n// 返回数据,继续传送数据\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 620,
"y": 120,
"wires": [
[
"85ea976f151fd9c0"
]
]
},
{
"id": "c90ccbf3b3169bd3",
"type": "comment",
"z": "de2440cb123a1d4d",
"g": "68c2fee3a5c928e7",
"name": "1、模拟http请求数据处理",
"info": "",
"x": 210,
"y": 60,
"wires": []
},
{
"id": "846c63bedd6a02c7",
"type": "comment",
"z": "de2440cb123a1d4d",
"g": "3207304905d4c422",
"name": "2、http请求多次处理",
"info": "",
"x": 190,
"y": 340,
"wires": []
},
{
"id": "41613eb507de7161",
"type": "inject",
"z": "de2440cb123a1d4d",
"g": "6cb5e2a9ea5d119a",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "10",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 170,
"y": 840,
"wires": [
[
"70413b9103b88586"
]
]
},
{
"id": "3c921ad95542f1ee",
"type": "debug",
"z": "de2440cb123a1d4d",
"g": "6cb5e2a9ea5d119a",
"name": "debug 4",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 650,
"y": 840,
"wires": []
},
{
"id": "70413b9103b88586",
"type": "function",
"z": "de2440cb123a1d4d",
"g": "6cb5e2a9ea5d119a",
"name": "function 3",
"func": "// 从payload创建一个Date对象\nvar date = new Date(msg.payload);\n\n// 时间加一天\ndate.setDate(date.getDate() + 1);\n\n// 格式化数据\nmsg.payload = date.toString();\n// 返回数据,继续传送数据\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 400,
"y": 840,
"wires": [
[
"3c921ad95542f1ee"
]
]
},
{
"id": "eae8c66f4f3ae57d",
"type": "comment",
"z": "de2440cb123a1d4d",
"g": "6cb5e2a9ea5d119a",
"name": "基础演示",
"info": "",
"x": 160,
"y": 780,
"wires": []
}
]
MQTT-示列
[
{
"id": "348f8e7e04cf02b3",
"type": "tab",
"label": "MQTT-示列",
"disabled": false,
"info": "",
"env": []
},
{
"id": "3229ed5ada94133f",
"type": "group",
"z": "348f8e7e04cf02b3",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"186942ee1e9dc0de",
"deffb411f491cb4a",
"6bcb486e15fbe74e",
"ce16a7ea1a3a065c",
"7699aaf37e442f20",
"38dc05da28d2c6b6"
],
"x": 174,
"y": 659,
"w": 972,
"h": 262
},
{
"id": "d556390223c2020e",
"type": "group",
"z": "348f8e7e04cf02b3",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"8a16c3bb6d755f6f",
"4801a2f2afff6d6e",
"2943df797ec0d798",
"e177e86b9a77a745",
"354de04f16fc608c",
"464d546e41402e8b",
"ab1316a0ed9a3ee2",
"7b37d40aca9152f5"
],
"x": 174,
"y": 1019,
"w": 1132,
"h": 242
},
{
"id": "2a27245260a94185",
"type": "group",
"z": "348f8e7e04cf02b3",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"b867afb525d77fa3",
"31756ae2bf6305b3",
"15ae54cd5bf05581",
"0f0077bc978b1d4d",
"d4d3d437487301e5",
"50e1e6e0d3506eab",
"84024ca5abe1c5e2",
"4c57f8ee2ecc730c",
"fc99bf4ed2702b55"
],
"x": 174,
"y": 59,
"w": 772,
"h": 462
},
{
"id": "50e1e6e0d3506eab",
"type": "mqtt in",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "MQTT订阅客户端",
"topic": "hello-topic",
"qos": "2",
"datatype": "auto-detect",
"broker": "8b11a1df6239c293",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 280,
"y": 480,
"wires": [
[
"fc99bf4ed2702b55"
]
]
},
{
"id": "84024ca5abe1c5e2",
"type": "debug",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "输出处理后MQTT消息",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 480,
"wires": []
},
{
"id": "b867afb525d77fa3",
"type": "mqtt out",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "MQTT发布客户端",
"topic": "hello-topic",
"qos": "0",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "8b11a1df6239c293",
"x": 810,
"y": 180,
"wires": []
},
{
"id": "31756ae2bf6305b3",
"type": "inject",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "定时产生消息",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"stringKey\":\"hello\",\"booleanKey\":true,\"doubleKey\":42,\"longKey\":73,\"jsonKey\":{\"temperature\":62.2,\"humidity\":79,\"someNumber\":42,\"someArray\":[1,2,3]}}",
"payloadType": "json",
"x": 310,
"y": 180,
"wires": [
[
"0f0077bc978b1d4d",
"b867afb525d77fa3"
]
]
},
{
"id": "15ae54cd5bf05581",
"type": "comment",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "1、定时产生MQTT消息",
"info": "",
"x": 300,
"y": 100,
"wires": []
},
{
"id": "4c57f8ee2ecc730c",
"type": "comment",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "2、订阅产生MQTT消息",
"info": "",
"x": 300,
"y": 420,
"wires": []
},
{
"id": "0f0077bc978b1d4d",
"type": "debug",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "输出产生的消息体",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 810,
"y": 280,
"wires": []
},
{
"id": "d4d3d437487301e5",
"type": "function",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "构建原始数据",
"func": "\n// 开始处理数据\n//数据转换处理\nlet obj = {\n miniAppId: \"wx7656607fe455b8ce\",\n miniAppSecret: \"ef3779d6260803c705db2b16e969e994\",\n miniVersion: \"develop\"\n};\n\nmsg.payload = obj;\n\n// 返回数据,继续传送数据\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 120,
"wires": [
[]
]
},
{
"id": "fc99bf4ed2702b55",
"type": "function",
"z": "348f8e7e04cf02b3",
"g": "2a27245260a94185",
"name": "原始数据处理",
"func": "// 开始处理数据\nvar resData = msg.payload ;\n\n//数据转换处理\n\nmsg.payload = resData.jsonKey;\n\n// 返回数据,继续传送数据\nreturn msg;\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 480,
"wires": [
[
"84024ca5abe1c5e2"
]
]
},
{
"id": "8a16c3bb6d755f6f",
"type": "comment",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "4、测试MQTT数据进行处理",
"info": "",
"x": 320,
"y": 1060,
"wires": []
},
{
"id": "4801a2f2afff6d6e",
"type": "mqtt in",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "/test/node-red/in",
"topic": "/test/node-red",
"qos": "1",
"datatype": "auto-detect",
"broker": "8b11a1df6239c293",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 280,
"y": 1120,
"wires": [
[
"2943df797ec0d798",
"ab1316a0ed9a3ee2"
]
]
},
{
"id": "2943df797ec0d798",
"type": "json",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "",
"property": "payload",
"action": "",
"pretty": true,
"x": 510,
"y": 1120,
"wires": [
[
"e177e86b9a77a745"
]
]
},
{
"id": "e177e86b9a77a745",
"type": "rbe",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload.temperature",
"topi": "topic",
"x": 730,
"y": 1120,
"wires": [
[
"354de04f16fc608c"
]
]
},
{
"id": "354de04f16fc608c",
"type": "template",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "The temperature value has changed!\n\nThis current value is payload: {{payload.temperature}}.",
"output": "str",
"x": 930,
"y": 1120,
"wires": [
[
"464d546e41402e8b",
"7b37d40aca9152f5"
]
]
},
{
"id": "464d546e41402e8b",
"type": "mqtt out",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "/test/node-red/out",
"topic": "/test/node-red",
"qos": "1",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "8b11a1df6239c293",
"x": 1190,
"y": 1120,
"wires": []
},
{
"id": "ab1316a0ed9a3ee2",
"type": "debug",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "/test/node-red/in",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 540,
"y": 1220,
"wires": []
},
{
"id": "7b37d40aca9152f5",
"type": "debug",
"z": "348f8e7e04cf02b3",
"g": "d556390223c2020e",
"name": "mqtt模板中的值",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1180,
"y": 1220,
"wires": []
},
{
"id": "186942ee1e9dc0de",
"type": "function",
"z": "348f8e7e04cf02b3",
"g": "3229ed5ada94133f",
"name": "设置动态订阅主题",
"func": "// 定义多条主题\nvar customTopics = [\n\"hello-topic\", \n\"/test/node-red\",\n\"Environment/temperature\"\n]; // 自定义的多条主题数组\n\n// 订阅 MQTT 主题\nvar newMsg = {\n action: \"subscribe\",\n topic: customTopics, // 要订阅的主题数组\n param: \"uart\",\n timestamp: Date.now() // 时间戳\n};\nnode.send(newMsg); // 发送新消息到下一个节点\nnode.status({ text: \"订阅主题数量: \" + customTopics.length });\n",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 470,
"y": 760,
"wires": [
[
"ce16a7ea1a3a065c",
"7699aaf37e442f20"
]
]
},
{
"id": "deffb411f491cb4a",
"type": "inject",
"z": "348f8e7e04cf02b3",
"g": "3229ed5ada94133f",
"name": "",
"props": [
{
"p": "payload",
"v": "",
"vt": "date"
},
{
"p": "topic",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 270,
"y": 760,
"wires": [
[
"186942ee1e9dc0de"
]
]
},
{
"id": "6bcb486e15fbe74e",
"type": "debug",
"z": "348f8e7e04cf02b3",
"g": "3229ed5ada94133f",
"name": "动态订阅设备主题-117",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1000,
"y": 760,
"wires": []
},
{
"id": "ce16a7ea1a3a065c",
"type": "mqtt in",
"z": "348f8e7e04cf02b3",
"g": "3229ed5ada94133f",
"name": "动态订阅设备主题",
"topic": "",
"qos": "0",
"datatype": "auto-detect",
"broker": "8b11a1df6239c293",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 1,
"x": 730,
"y": 760,
"wires": [
[
"6bcb486e15fbe74e"
]
]
},
{
"id": "7699aaf37e442f20",
"type": "debug",
"z": "348f8e7e04cf02b3",
"g": "3229ed5ada94133f",
"name": "设置动态订阅主题-119",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 880,
"wires": []
},
{
"id": "38dc05da28d2c6b6",
"type": "comment",
"z": "348f8e7e04cf02b3",
"g": "3229ed5ada94133f",
"name": "3、MQTT动态订阅主题",
"info": "",
"x": 300,
"y": 700,
"wires": []
},
{
"id": "8b11a1df6239c293",
"type": "mqtt-broker",
"name": "",
"broker": "127.0.0.1",
"port": "61613",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
TCP-示列
[
{
"id": "f4a4d8eab7935bc8",
"type": "tab",
"label": "TCP-示列2",
"disabled": false,
"info": "# https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/124195637",
"env": []
},
{
"id": "4843765b.1af508",
"type": "tcp in",
"z": "f4a4d8eab7935bc8",
"name": "TCP客戶端:1025",
"server": "client",
"host": "127.0.0.1",
"port": "1025",
"datamode": "stream",
"datatype": "utf8",
"newline": "\\n",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 260,
"y": 620,
"wires": [
[
"a4f8ed1e.c28a3",
"27457a99.3109b6"
]
]
},
{
"id": "a4f8ed1e.c28a3",
"type": "debug",
"z": "f4a4d8eab7935bc8",
"name": "tcp client",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 480,
"y": 760,
"wires": []
},
{
"id": "27457a99.3109b6",
"type": "tcp out",
"z": "f4a4d8eab7935bc8",
"name": "tcp out : 送出信息",
"host": "",
"port": "",
"beserver": "reply",
"base64": false,
"end": false,
"tls": "",
"x": 990,
"y": 620,
"wires": []
},
{
"id": "1a88d1d5.c129ae",
"type": "inject",
"z": "f4a4d8eab7935bc8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "temp",
"payloadType": "str",
"x": 450,
"y": 560,
"wires": [
[
"f1c7c3d.6a92c4"
]
]
},
{
"id": "d0ed337.b37dbd",
"type": "tcp in",
"z": "f4a4d8eab7935bc8",
"name": "TCP服务端:1025",
"server": "server",
"host": "",
"port": "1025",
"datamode": "stream",
"datatype": "utf8",
"newline": "\\n",
"topic": "",
"trim": false,
"base64": false,
"tls": "",
"x": 240,
"y": 140,
"wires": [
[
"a8ca6d2c.2926c",
"c3baaed4.79a65"
]
]
},
{
"id": "c4fce4d0.df1838",
"type": "tcp out",
"z": "f4a4d8eab7935bc8",
"name": "tcp out: 发送信息",
"host": "",
"port": "",
"beserver": "reply",
"base64": false,
"end": false,
"x": 1170,
"y": 140,
"wires": []
},
{
"id": "a8ca6d2c.2926c",
"type": "debug",
"z": "f4a4d8eab7935bc8",
"name": "tcp server",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 460,
"y": 320,
"wires": []
},
{
"id": "c3baaed4.79a65",
"type": "switch",
"z": "f4a4d8eab7935bc8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "temp",
"vt": "str"
},
{
"t": "eq",
"v": "humi",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 450,
"y": 140,
"wires": [
[
"9986631d.c94df"
],
[
"862b30b1.af802"
]
]
},
{
"id": "9986631d.c94df",
"type": "change",
"z": "f4a4d8eab7935bc8",
"name": "输出: 20",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "20",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 120,
"wires": [
[
"df1d0ca7.57683"
]
]
},
{
"id": "f1c7c3d.6a92c4",
"type": "template",
"z": "f4a4d8eab7935bc8",
"name": "+ 換行",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "{{payload}}\n",
"output": "str",
"x": 630,
"y": 540,
"wires": [
[
"27457a99.3109b6"
]
]
},
{
"id": "2ddba953.d7ae06",
"type": "inject",
"z": "f4a4d8eab7935bc8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "humi",
"payloadType": "str",
"x": 450,
"y": 520,
"wires": [
[
"f1c7c3d.6a92c4"
]
]
},
{
"id": "862b30b1.af802",
"type": "change",
"z": "f4a4d8eab7935bc8",
"name": "输出: 70",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "70",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 160,
"wires": [
[
"df1d0ca7.57683"
]
]
},
{
"id": "df1d0ca7.57683",
"type": "template",
"z": "f4a4d8eab7935bc8",
"name": "+换行",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "{{payload}}\n",
"output": "str",
"x": 810,
"y": 140,
"wires": [
[
"dd4e77a442e92660"
]
]
},
{
"id": "12ecae70c3de5088",
"type": "inject",
"z": "f4a4d8eab7935bc8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Hello from server.",
"payloadType": "str",
"x": 600,
"y": 60,
"wires": [
[
"df1d0ca7.57683"
]
]
},
{
"id": "8471c767c39096a9",
"type": "function",
"z": "f4a4d8eab7935bc8",
"name": "函数",
"func": "var payload = msg.payload.toString();\n\nmsg.payload = {\"tcp\": payload}\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 450,
"y": 240,
"wires": [
[
"4109f61a87e0b709"
]
]
},
{
"id": "4109f61a87e0b709",
"type": "mqtt out",
"z": "f4a4d8eab7935bc8",
"name": "上传遥测",
"topic": "v1/devices/telemetry",
"qos": "1",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "8b11a1df6239c293",
"x": 620,
"y": 240,
"wires": []
},
{
"id": "e5be6324645693c4",
"type": "mqtt in",
"z": "f4a4d8eab7935bc8",
"name": "订阅MQTT消息",
"topic": "v1/devices/temp",
"qos": "1",
"datatype": "auto-detect",
"broker": "8b11a1df6239c293",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 420,
"y": 460,
"wires": [
[]
]
},
{
"id": "dd4e77a442e92660",
"type": "delay",
"z": "f4a4d8eab7935bc8",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 980,
"y": 140,
"wires": [
[
"c4fce4d0.df1838"
]
]
},
{
"id": "884f79cc.ff01d8",
"type": "function",
"z": "f4a4d8eab7935bc8",
"name": "no msg back",
"func": "",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 650,
"y": 680,
"wires": [
[]
]
},
{
"id": "8b11a1df6239c293",
"type": "mqtt-broker",
"name": "",
"broker": "127.0.0.1",
"port": "61613",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
MQTT-Modbus示列
[
{
"id": "d9506c2bbcecf909",
"type": "tab",
"label": "MQTT-Modbus示列",
"disabled": false,
"info": "",
"env": []
},
{
"id": "f4ec80708ef35fc6",
"type": "modbus-getter",
"z": "d9506c2bbcecf909",
"name": "水位",
"showStatusActivities": true,
"showErrors": false,
"showWarnings": true,
"logIOActivities": false,
"unitid": "1",
"dataType": "HoldingRegister",
"adr": "1",
"quantity": "3",
"server": "ce08db4b7d9f20f0",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"delayOnStart": false,
"startDelayTime": "",
"x": 390,
"y": 360,
"wires": [
[
"15f2878dff93f895"
],
[]
]
},
{
"id": "11b03710e3fbaeb1",
"type": "modbus-getter",
"z": "d9506c2bbcecf909",
"name": "水温",
"showStatusActivities": true,
"showErrors": false,
"showWarnings": true,
"logIOActivities": false,
"unitid": "1",
"dataType": "HoldingRegister",
"adr": "2",
"quantity": "3",
"server": "ce08db4b7d9f20f0",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"delayOnStart": false,
"startDelayTime": "",
"x": 390,
"y": 460,
"wires": [
[
"53525a6164965ba8"
],
[]
]
},
{
"id": "e8db4c544769e572",
"type": "inject",
"z": "d9506c2bbcecf909",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "10",
"topic": "",
"payload": "",
"payloadType": "str",
"x": 190,
"y": 380,
"wires": [
[
"f4ec80708ef35fc6",
"3ce7d5365f53c405"
]
]
},
{
"id": "821ad40fe1d1982a",
"type": "debug",
"z": "d9506c2bbcecf909",
"name": "输出水箱参数",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 480,
"y": 620,
"wires": []
},
{
"id": "3ce7d5365f53c405",
"type": "delay",
"z": "d9506c2bbcecf909",
"name": "",
"pauseType": "delay",
"timeout": "10",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 250,
"y": 440,
"wires": [
[
"11b03710e3fbaeb1"
]
]
},
{
"id": "15f2878dff93f895",
"type": "function",
"z": "d9506c2bbcecf909",
"name": "水位",
"func": "msg={topic:\"WaterLevel\",payload:msg.payload[0]}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 360,
"wires": [
[
"ea5ef161c502483a"
]
]
},
{
"id": "53525a6164965ba8",
"type": "function",
"z": "d9506c2bbcecf909",
"name": "水温",
"func": "msg={topic:\"WaterTemp\",payload:msg.payload[0],complete:true}\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 460,
"wires": [
[
"ea5ef161c502483a"
]
]
},
{
"id": "52ca0c1bb0f19e8d",
"type": "mqtt out",
"z": "d9506c2bbcecf909",
"name": "",
"topic": "WaterTank",
"qos": "0",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "8b11a1df6239c293",
"x": 850,
"y": 400,
"wires": []
},
{
"id": "ecdd64a18cb47ba0",
"type": "mqtt in",
"z": "d9506c2bbcecf909",
"name": "",
"topic": "WaterTank",
"qos": "0",
"datatype": "auto-detect",
"broker": "8b11a1df6239c293",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 180,
"y": 620,
"wires": [
[
"821ad40fe1d1982a"
]
]
},
{
"id": "ea5ef161c502483a",
"type": "join",
"z": "d9506c2bbcecf909",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"useparts": true,
"accumulate": true,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 690,
"y": 400,
"wires": [
[
"52ca0c1bb0f19e8d"
]
]
},
{
"id": "191c3764b44f142d",
"type": "comment",
"z": "d9506c2bbcecf909",
"name": "1. 用于演示的MQTT代理",
"info": "",
"x": 230,
"y": 120,
"wires": []
},
{
"id": "c3e91315d67397ab",
"type": "comment",
"z": "d9506c2bbcecf909",
"name": "2. 通过Modbus分别采集水箱的水位和温度,合并为水箱参数,由MQTT客户端发布",
"info": "",
"x": 410,
"y": 300,
"wires": []
},
{
"id": "d30378515c340137",
"type": "comment",
"z": "d9506c2bbcecf909",
"name": "3. 订阅水箱参数",
"info": "",
"x": 200,
"y": 580,
"wires": []
},
{
"id": "0e0579f7e2d10b4b",
"type": "aedes broker",
"z": "d9506c2bbcecf909",
"name": "",
"mqtt_port": 1883,
"mqtt_ws_bind": "port",
"mqtt_ws_port": "",
"mqtt_ws_path": "",
"cert": "",
"key": "",
"certname": "",
"keyname": "",
"persistence_bind": "memory",
"dburl": "",
"usetls": false,
"x": 210,
"y": 160,
"wires": [
[],
[]
]
},
{
"id": "ce08db4b7d9f20f0",
"type": "modbus-client",
"name": "Modbus Slave TCP",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": true,
"tcpHost": "127.0.0.1",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "com4",
"serialType": "RTU",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": 1,
"commandDelay": 1,
"clientTimeout": 1000,
"reconnectOnTimeout": true,
"reconnectTimeout": 2000,
"parallelUnitIdsAllowed": true
},
{
"id": "8b11a1df6239c293",
"type": "mqtt-broker",
"name": "",
"broker": "127.0.0.1",
"port": "61613",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
Node-RED 综合示列示列
[
{
"id": "9e2816f2d9a56558",
"type": "tab",
"label": "Node-RED应用示列",
"disabled": false,
"info": "# 应用举例\r\n# https://wenku.csdn.net/column/3g4ju4yi8g\r\n\r\n# Node-RED中的消息传递与消息转换\r\n# https://wenku.csdn.net/column/57ih7t24d9?spm=1055.2635.3001.10023.3",
"env": []
},
{
"id": "91db2bbb32b68883",
"type": "group",
"z": "9e2816f2d9a56558",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"f83dfc8c.b314a8",
"cc5921b7.658a38",
"b5e087b5.924b08",
"18be3e61.2b3da6",
"e69d26a6.b2f51",
"80f9374d.e72538",
"112ba4cba7075e4c"
],
"x": 114,
"y": 59,
"w": 832,
"h": 242
},
{
"id": "cc46f8eb179ddeea",
"type": "group",
"z": "9e2816f2d9a56558",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"bc4afa74.04213",
"de4ee49e.26d3a8",
"a6d7a59a.3f6668",
"d4d5ecaf439beed5"
],
"x": 114,
"y": 379,
"w": 682,
"h": 142
},
{
"id": "1f791e43cc8850f2",
"type": "group",
"z": "9e2816f2d9a56558",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"e1528fa0.e056f",
"25c60f50.490c82",
"3d6fc19f.ca17e2",
"2284eb4f83d4e681"
],
"x": 114,
"y": 619,
"w": 582,
"h": 162
},
{
"id": "de835f80231c2673",
"type": "group",
"z": "9e2816f2d9a56558",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"c12a0692c812f9b1",
"d5792ea0aca2b6db",
"9ceaf52226729f6d",
"032163b81ff721bd"
],
"x": 114,
"y": 899,
"w": 772,
"h": 142
},
{
"id": "f83dfc8c.b314a8",
"type": "mqtt in",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "Sensor Input",
"topic": "sensor/data",
"qos": "2",
"datatype": "auto-detect",
"broker": "8b11a1df6239c293",
"nl": false,
"rap": false,
"inputs": 0,
"x": 210,
"y": 180,
"wires": [
[
"cc5921b7.658a38"
]
]
},
{
"id": "cc5921b7.658a38",
"type": "switch",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "Data Range",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lte",
"v": "10",
"vt": "num"
},
{
"t": "btwn",
"v": "11",
"v2": "20",
"vt": "num",
"v2t": "num"
},
{
"t": "gt",
"v": "20",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 390,
"y": 180,
"wires": [
[
"b5e087b5.924b08"
],
[
"18be3e61.2b3da6"
],
[
"e69d26a6.b2f51"
]
]
},
{
"id": "b5e087b5.924b08",
"type": "function",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "Process <= 10",
"func": "msg.topic = \"low-range\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 140,
"wires": [
[
"80f9374d.e72538"
]
]
},
{
"id": "18be3e61.2b3da6",
"type": "function",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "Process 11-20",
"func": "msg.topic = \"medium-range\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 200,
"wires": [
[
"80f9374d.e72538"
]
]
},
{
"id": "e69d26a6.b2f51",
"type": "function",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "Process > 20",
"func": "msg.topic = \"high-range\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 260,
"wires": [
[
"80f9374d.e72538"
]
]
},
{
"id": "80f9374d.e72538",
"type": "mqtt out",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "Output",
"topic": "",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "8b11a1df6239c293",
"x": 870,
"y": 200,
"wires": []
},
{
"id": "bc4afa74.04213",
"type": "inject",
"z": "9e2816f2d9a56558",
"g": "cc46f8eb179ddeea",
"name": "Simulate API Data",
"props": [
{
"p": "payload",
"v": "{\"name\": \"Alice\", \"age\": 25, \"gender\": \"female\"}",
"vt": "json"
},
{
"p": "topic",
"v": "",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"name\": \"Alice\", \"age\": 25, \"gender\": \"female\"}",
"payloadType": "json",
"x": 250,
"y": 480,
"wires": [
[
"de4ee49e.26d3a8"
]
]
},
{
"id": "de4ee49e.26d3a8",
"type": "function",
"z": "9e2816f2d9a56558",
"g": "cc46f8eb179ddeea",
"name": "JSON Parse & Transform",
"func": "msg.name = msg.payload.name;\nmsg.info = `Age: ${msg.payload.age}, Gender: ${msg.payload.gender}`;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 480,
"y": 480,
"wires": [
[
"a6d7a59a.3f6668"
]
]
},
{
"id": "a6d7a59a.3f6668",
"type": "debug",
"z": "9e2816f2d9a56558",
"g": "cc46f8eb179ddeea",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 680,
"y": 480,
"wires": []
},
{
"id": "112ba4cba7075e4c",
"type": "comment",
"z": "9e2816f2d9a56558",
"g": "91db2bbb32b68883",
"name": "示例场景:数据筛选与分类",
"info": "示例场景:数据筛选与分类",
"x": 250,
"y": 100,
"wires": []
},
{
"id": "d4d5ecaf439beed5",
"type": "comment",
"z": "9e2816f2d9a56558",
"g": "cc46f8eb179ddeea",
"name": "示例场景:JSON数据解析与转换",
"info": "",
"x": 270,
"y": 420,
"wires": []
},
{
"id": "e1528fa0.e056f",
"type": "http request",
"z": "9e2816f2d9a56558",
"g": "1f791e43cc8850f2",
"name": "Fetch Data",
"method": "GET",
"ret": "obj",
"url": "https://api.example.com/data",
"tls": "",
"x": 210,
"y": 740,
"wires": [
[
"25c60f50.490c82"
]
]
},
{
"id": "25c60f50.490c82",
"type": "function",
"z": "9e2816f2d9a56558",
"g": "1f791e43cc8850f2",
"name": "Process Data",
"func": "msg.payload = `Received data: ${msg.payload}`;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 400,
"y": 740,
"wires": [
[
"3d6fc19f.ca17e2"
]
]
},
{
"id": "3d6fc19f.ca17e2",
"type": "debug",
"z": "9e2816f2d9a56558",
"g": "1f791e43cc8850f2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 580,
"y": 740,
"wires": []
},
{
"id": "2284eb4f83d4e681",
"type": "comment",
"z": "9e2816f2d9a56558",
"g": "1f791e43cc8850f2",
"name": "示例场景:使用HTTP请求调用外部API",
"info": "",
"x": 290,
"y": 660,
"wires": []
},
{
"id": "c12a0692c812f9b1",
"type": "postgresql",
"z": "9e2816f2d9a56558",
"g": "de835f80231c2673",
"name": "运营云开发环境-查询数据",
"query": "SELECT * FROM \"pig\".\"sys_user\";",
"postgreSQLConfig": "70fc2c7562981cab",
"split": false,
"rowsPerMsg": 1,
"outputs": 1,
"x": 470,
"y": 1000,
"wires": [
[
"9ceaf52226729f6d"
]
]
},
{
"id": "d5792ea0aca2b6db",
"type": "inject",
"z": "9e2816f2d9a56558",
"g": "de835f80231c2673",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 210,
"y": 1000,
"wires": [
[
"c12a0692c812f9b1"
]
]
},
{
"id": "9ceaf52226729f6d",
"type": "debug",
"z": "9e2816f2d9a56558",
"g": "de835f80231c2673",
"name": "PostgreSQL-debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 750,
"y": 1000,
"wires": []
},
{
"id": "032163b81ff721bd",
"type": "comment",
"z": "9e2816f2d9a56558",
"g": "de835f80231c2673",
"name": "示例场景:PostgreSQL",
"info": "",
"x": 240,
"y": 940,
"wires": []
},
{
"id": "8b11a1df6239c293",
"type": "mqtt-broker",
"name": "",
"broker": "127.0.0.1",
"port": "61613",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "70fc2c7562981cab",
"type": "postgreSQLConfig",
"name": "运营云本地环境",
"host": "sh-postgres-0n80blnk.sql.tencentcdb.com",
"hostFieldType": "str",
"port": "20386",
"portFieldType": "num",
"database": "aio-devops",
"databaseFieldType": "str",
"ssl": "false",
"sslFieldType": "bool",
"applicationName": "",
"applicationNameType": "str",
"max": "10",
"maxFieldType": "num",
"idle": "1000",
"idleFieldType": "num",
"connectionTimeout": "10000",
"connectionTimeoutFieldType": "num",
"user": "cloud_dev_pg",
"userFieldType": "str",
"password": "Dahuacloud123#@!.",
"passwordFieldType": "str"
}
]
标签:Node,wires,false,name,true,网络工具,type,id,RED
From: https://blog.csdn.net/u013289939/article/details/141281983