Hi, i have multiple MQTT topics and i need to send individual payload at same time to different MQTT topic.
The issue is if i use msg.payload - the JSON frames will be overwritten. I did explore a path where i tried to create msg.test1 and msg.test2 with JSON payload but the issue is how can my MQTT node will not work with this format.
How can i manage this situation.?
code
[
{
"id": "46a7f55b3dc113fa",
"type": "tab",
"label": "Flow 3",
"disabled": false,
"info": "",
"env": []
},
{
"id": "f90132623ba1efaa",
"type": "inject",
"z": "46a7f55b3dc113fa",
"name": "inject",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 110,
"y": 200,
"wires": [
[
"3120844e6d7228c6",
"08788246c8d75e3e"
]
]
},
{
"id": "3120844e6d7228c6",
"type": "function",
"z": "46a7f55b3dc113fa",
"name": "test1",
"func": "msg.test1={\n\"temperature\" : 20,\n\"pressure\" : 2\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 160,
"wires": [
[
"7a010a252dc12b7b",
"6264ca3a4d52b995"
]
]
},
{
"id": "08788246c8d75e3e",
"type": "function",
"z": "46a7f55b3dc113fa",
"name": "test2",
"func": "msg.test2={\n\"humidity\" : 89,\n\"load\" : 30,\n\"time\" : \"\"\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 240,
"wires": [
[
"d806c099180ea2d3"
]
]
},
{
"id": "7a010a252dc12b7b",
"type": "mqtt out",
"z": "46a7f55b3dc113fa",
"name": "",
"topic": "topic1",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "272c1aebb3ef8a9a",
"x": 610,
"y": 120,
"wires": []
},
{
"id": "d806c099180ea2d3",
"type": "mqtt out",
"z": "46a7f55b3dc113fa",
"name": "",
"topic": "topic2",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "272c1aebb3ef8a9a",
"x": 590,
"y": 260,
"wires": []
},
{
"id": "6264ca3a4d52b995",
"type": "debug",
"z": "46a7f55b3dc113fa",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "test1",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 560,
"y": 60,
"wires": []
},
{
"id": "65c1bfd5cb2f1feb",
"type": "debug",
"z": "46a7f55b3dc113fa",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "test2",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 520,
"y": 320,
"wires": []
},
{
"id": "272c1aebb3ef8a9a",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.1.29",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]