I have a conditional loop node that is supposed to exit when a counter gets to 100. It starts with an injection node that is set to repeat at a specific time, early in the morning before I get up, and when I log onto the server later on, the debug window is showing it's still running well past 100. I copied the loop nodes, and set a smaller delay to test, and it works as expected when I run it separately.
I added a line to the function node to keep it to maximum of 100, I'll check to see how that affects the runtime tomorrow morning, but I assume instead of seeing it counting up past 100, I'll end up with it continuing to output '100' to the debug window.
Is there a reason why the timed injection would work differently? This is exactly the same code I am using, minus the repeat option (and a lower delay value).
[
{
"id": "68f320f33a70cd0b",
"type": "change",
"z": "0fb6b4cf527db2b5",
"name": "Set initial value",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 660,
"wires": [
[
"8aa222b7986a6f3e"
]
]
},
{
"id": "8aa222b7986a6f3e",
"type": "loop",
"z": "0fb6b4cf527db2b5",
"name": "",
"kind": "cond",
"count": "10",
"initial": "1",
"step": "1",
"condition": "msg.payload < 100",
"conditionType": "js",
"when": "before",
"enumeration": "enum",
"enumerationType": "msg",
"limit": "1200000000",
"loopPayload": "loop-keep",
"finalPayload": "final-last",
"x": 400,
"y": 700,
"wires": [
[
"a9b392782147f78f"
],
[
"c4afafb52d072ee5"
]
]
},
{
"id": "c4afafb52d072ee5",
"type": "function",
"z": "0fb6b4cf527db2b5",
"name": "Increment function",
"func": "var i = msg.payload\n\ni = 1 + i\n\nmsg.payload = Math.min(i, 100)\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 410,
"y": 780,
"wires": [
[
"337b4ea4fac670dc",
"602cfb94efe73a8e"
]
]
},
{
"id": "337b4ea4fac670dc",
"type": "delay",
"z": "0fb6b4cf527db2b5",
"name": "",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"x": 390,
"y": 820,
"wires": [
[
"8aa222b7986a6f3e"
]
]
},
{
"id": "602cfb94efe73a8e",
"type": "debug",
"z": "0fb6b4cf527db2b5",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 730,
"y": 780,
"wires": []
},
{
"id": "a9b392782147f78f",
"type": "debug",
"z": "0fb6b4cf527db2b5",
"name": "Exit loop",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "loop",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 720,
"y": 680,
"wires": []
},
{
"id": "d83cd8c82738598e",
"type": "inject",
"z": "0fb6b4cf527db2b5",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 120,
"y": 660,
"wires": [
[
"68f320f33a70cd0b"
]
]
}
]