I recieve a string from another Node and want to check and convert it in the following function node.
When I inject a string in the function node, only the input values will be shown in the debug node.
Maybe someone will see the mistake at first sight and can help me with this problem.
var Feuchte = msg.payload;
var Zähler1 = 0;
var Zähler2 = 0;
if (Feuchte >= 69)
{
Zähler1++;
if (Zähler1 >= 3)
{
msg.payload = 1;
Zähler1 = 0;
}
}
else if (Feuchte <= 58)
{
Zähler2++;
if (Zähler2 >= 3)
{
msg.payload = 2;
Zähler2 = 0;
}
}
return msg;
Here's my complete flow:
[
{
"id": "faff91a2a3f67c7b",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": ""
},
{
"id": "8173dc7f896278bf",
"type": "inject",
"z": "faff91a2a3f67c7b",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "71",
"payloadType": "str",
"x": 270,
"y": 140,
"wires": [
[
"1f22d8b398c05b56"
]
]
},
{
"id": "6f39213c12a643c6",
"type": "inject",
"z": "faff91a2a3f67c7b",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "28",
"payloadType": "str",
"x": 270,
"y": 180,
"wires": [
[
"1f22d8b398c05b56"
]
]
},
{
"id": "1f22d8b398c05b56",
"type": "function",
"z": "faff91a2a3f67c7b",
"name": "IF - ELSE Verzweigung",
"func": "var Feuchte = msg.payload;\nvar Zähler1 = 0;\nvar Zähler2 = 0;\n\nif (Feuchte >= 69)\n{\n Zähler1++;\n \n if (Zähler1 >= 3)\n {\n msg.payload = 1;\n Zähler1 = 0;\n }\n}\nelse if (Feuchte <= 58)\n{\n Zähler2++;\n if (Zähler2 >= 3)\n {\n msg.payload = 2;\n Zähler2 = 0;\n }\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 160,
"wires": [
[
"72595f921dd14257"
]
]
},
{
"id": "72595f921dd14257",
"type": "debug",
"z": "faff91a2a3f67c7b",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 770,
"y": 160,
"wires": []
}
]