hi guys,
I wanna import two different payloads (with two different topics) to a function node and use them to calculate someting. At the end the result should be send out as a payload again.
I get the two values from another flow, that´s working. If I replace the two variables with static values, the funtion node works. But not using the payloads. Any hints for a beginner?
Regards
[
{
"id": "df744e750e5a9e81",
"type": "tab",
"label": "Taupunkte",
"disabled": false,
"info": "",
"env": []
},
{
"id": "589a22c4f044264e",
"type": "function",
"z": "df744e750e5a9e81",
"name": "Td außen",
"func": "var es = { };\nvar ed = { };\nvar eln = { };\nvar td = { };\nvar msg1 = {};\nvar msg3 = {};\nmsg1.payload = msg.payload.tempout;\nmsg3.payload = msg.payload.humidityout;\nif (msg1.payload >= 0)\n{\n\t\t es.payload = 6.1078*Math.pow(10,((7.5*msg1.payload)/(237.3 + msg1.payload)));\n\t\t ed.payload = msg3.payload/100.0*es.payload;\n\t\t eln.payload = Math.log10(ed.payload/6.1078);\n\t\t\ttd.payload = 237.3*eln.payload/(7.5 - eln.payload);\n}\nelse\n{\n\t\t es.payload = 6.1078*Math.pow(10,((7.6*msg1.payload)/(240.7 + msg1.payload)));\n\t\t ed.payload = msg3.payload/100.0*es.payload;\n\t\t eln.payload = Math.log10(ed.payload/6.1078);\n\t\t\ttd.payload = 240.7*eln.payload/(7.6 - eln.payload);\n}\nreturn [msg1,msg3];",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 500,
"y": 120,
"wires": [
[
"a4cc9938fa255750"
]
]
},
{
"id": "e3019f3175327953",
"type": "link in",
"z": "df744e750e5a9e81",
"name": "Humidity out",
"links": [
"995f7c2d3ba33d99"
],
"x": 65,
"y": 140,
"wires": [
[
"da8bfa18928117f9"
]
]
},
{
"id": "33412de7df28bca2",
"type": "link in",
"z": "df744e750e5a9e81",
"name": "Temp out",
"links": [
"ffc8b882aa95a7cd"
],
"x": 65,
"y": 100,
"wires": [
[
"f860fc114b0a2b09"
]
]
},
{
"id": "a4cc9938fa255750",
"type": "debug",
"z": "df744e750e5a9e81",
"name": "debug 11",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1100,
"y": 100,
"wires": []
},
{
"id": "da8bfa18928117f9",
"type": "change",
"z": "df744e750e5a9e81",
"name": "",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "humidityout",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 200,
"y": 140,
"wires": [
[
"54d2c21d96f0c541",
"589a22c4f044264e"
]
]
},
{
"id": "35bcef6655a8a3ca",
"type": "debug",
"z": "df744e750e5a9e81",
"name": "tempout",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 400,
"y": 40,
"wires": []
},
{
"id": "54d2c21d96f0c541",
"type": "debug",
"z": "df744e750e5a9e81",
"name": "humidityout",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 410,
"y": 200,
"wires": []
},
{
"id": "f860fc114b0a2b09",
"type": "change",
"z": "df744e750e5a9e81",
"name": "",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "tempout",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 200,
"y": 100,
"wires": [
[
"35bcef6655a8a3ca",
"589a22c4f044264e"
]
]
}
]