do-red
Version:
A do-node and corresponding return-node for creating loops and task-lists.
1,960 lines (1,959 loc) • 106 kB
JSON
[
{
"id": "d9faa645.5bfcf8",
"type": "tab",
"label": "loop",
"disabled": false,
"info": ""
},
{
"id": "8b50971b.a49d58",
"type": "tab",
"label": "task list",
"disabled": false,
"info": ""
},
{
"id": "19507521.e9188b",
"type": "tab",
"label": "abort",
"disabled": false,
"info": ""
},
{
"id": "98c1572b.950998",
"type": "tab",
"label": "overlapping task lists",
"disabled": false,
"info": ""
},
{
"id": "a37ba4fb4c0f75b5",
"type": "tab",
"label": "each",
"disabled": false,
"info": ""
},
{
"id": "219e53717be7388e",
"type": "tab",
"label": "mark nodes test",
"disabled": false,
"info": "",
"env": []
},
{
"id": "d6a9334c12c71996",
"type": "subflow",
"name": "smile subflow",
"info": "",
"category": "",
"in": [
{
"x": 60,
"y": 120,
"wires": [
{
"id": "bfdf8ef2.7266a"
}
]
}
],
"out": [],
"env": [],
"meta": {},
"color": "#DDAA99"
},
{
"id": "69a9876fcaa7b188",
"type": "subflow",
"name": "Subflow 1",
"info": "",
"category": "",
"in": [
{
"x": 60,
"y": 80,
"wires": []
}
],
"out": [
{
"x": 200,
"y": 80,
"wires": [
{
"id": "69a9876fcaa7b188",
"port": 0
}
]
}
],
"env": [],
"meta": {},
"color": "#DDAA99"
},
{
"id": "13801fdd6b5b4fa2",
"type": "group",
"z": "a37ba4fb4c0f75b5",
"name": "",
"style": {
"label": true
},
"nodes": [
"9f805e9c08470329",
"bd3ea16681f75a48",
"6ed13f9be5e114b7",
"ec13c40821918014",
"3572247be8af7f3d",
"db011552a95b3c4b",
"e88ffe5ac5c0e1cc",
"f6abb27126a0451d",
"43ac74b2f62b1a00",
"c64e8966c886ed56",
"c848fbb8bcf13c73",
"fa6c84b86112dacf",
"6d3e7a5685df6118",
"88413b561f1fa8ad",
"8633e8cd8755d41e",
"0b679b604339a0f5",
"2c7a327d51775f1b",
"46f9cf59ba916358",
"fb86275488bfe72d",
"92577a77fc14f3df",
"0a01060611f50b89",
"9dd3cb82ca403cd8",
"6bd6b4852ebd8cef",
"2c687a8db5ad2d7d",
"7fe39e1936da5497"
],
"x": 54,
"y": 39,
"w": 1252,
"h": 622
},
{
"id": "156e48294e15a399",
"type": "group",
"z": "a37ba4fb4c0f75b5",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"3df32a9ffbb5242a",
"a11a09b08407dc50",
"631d6b526bea7e4d",
"0a06ba357340e2d3",
"091b1cb23ef8485e",
"fa63bd549cae8b41",
"e33fc812f873369b",
"333892a0ea4ade46",
"ba827510167634bd",
"004c984fdb5923ca",
"54c16615e721f476",
"9cb922e4f6891085",
"7572d26446ddf8f9"
],
"x": 54,
"y": 1379,
"w": 1132,
"h": 342
},
{
"id": "9df54a142a4bddf1",
"type": "group",
"z": "a37ba4fb4c0f75b5",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"c712565fe629a8b5",
"89b76248799543f0",
"098245f2db6a16ce",
"59d31a51e31dd8aa",
"663353f613d517ab",
"4f69b439ce7b954e",
"6e060feb4ec85989",
"04b5a2ec2c7ea1b9",
"e74cafe822752aee",
"f657e43da9571001",
"dc2c9c21b92ad433",
"9be31c0756c32141",
"5d2debdf8162371b",
"d49352494dc53b12",
"80e1a07a26db735b",
"e75b5f7903ac8597",
"944458cb4ec11494",
"bf491cbe1425c4d2",
"d562b47c01c791c3",
"19015160fcdf862f",
"62b55aab9f60e142",
"da789c49f0b2f636",
"36ced97cf601143d",
"a4704c83cdbea31e",
"69a43c2e8b7b3aec",
"052c6324621a0ee4",
"83fbcfa575479023",
"4238567a740c868e",
"de5035e88890d192",
"f4d933bac346eff7"
],
"x": 54,
"y": 719,
"w": 952,
"h": 622
},
{
"id": "71befdec94a6e39a",
"type": "group",
"z": "219e53717be7388e",
"name": "no ops",
"style": {
"label": true
},
"nodes": [
"0299c2dc30800902",
"8a6bdafa79bd5ad8",
"4c7774f24234c17a",
"7f43dc2b7a53e606",
"1d9b0b9d954b4606"
],
"x": 154,
"y": 199,
"w": 570.1041717529297,
"h": 142.09722900390625
},
{
"id": "a92bd9295a150eeb",
"type": "group",
"z": "219e53717be7388e",
"name": "done output",
"style": {
"label": true
},
"nodes": [
"6ce39b0ad502df7a",
"f99f30f5c03eb807",
"306bd815ce3d485e",
"4b2073ed74c8f5ff",
"e6f70b4527bc8478",
"efa7d8d40d62ba64",
"8b4ca6e521e8a69b",
"2e78208cab19461c",
"c605d293cbf873cd",
"444cc5531e203471",
"dc0251a8d2eb0a52",
"cb6089b04bd32cda",
"5d9a847576354e96",
"231ef7ae7a4099dc",
"052985dc8bea8b6e",
"c236dfcbb02ccdf1",
"7c7668662a9408f2",
"b998735cc6134a25",
"378f86f8d0438a1b",
"4eeb51b871edc180",
"8d4360664ba1c7e9",
"cfb4e912d5e2d474",
"81fdcc7f1b886714",
"28031bb9ccbaae76",
"729766a1a6a54faa",
"1dd33cf575405dee",
"6bca9dcf4a5c294b"
],
"x": 154,
"y": 399,
"w": 812,
"h": 822
},
{
"id": "9a8d2dcf0c565a29",
"type": "group",
"z": "219e53717be7388e",
"name": "task only",
"style": {
"label": true
},
"nodes": [
"a96677f29da86541",
"5d5180e667155405",
"741563e8acab30dd",
"786e65a425174ffe",
"83f8269e090842c2",
"14fb680208da3f0e",
"426af6e59cda9255",
"3864fd3615f793c9",
"a69c3a5e418d6815",
"b7c153761700738e",
"546babcb8757c455",
"2a9d6ab61d665a7d",
"81586e3507b56d44",
"92c2f04da248a8d7",
"f0e67bec21de000c",
"f2a9aa6f62e3c50f",
"d2fc6a9a9a940bec",
"c96e0b82eca069ef",
"e55cde324d714932",
"040be4ccd3ca7e74",
"595888d4f80ab4a6",
"216a5a4ccfc54828"
],
"x": 1074,
"y": 399,
"w": 872,
"h": 542
},
{
"id": "cf738bbd1450c95f",
"type": "junction",
"z": "98c1572b.950998",
"x": 520,
"y": 100,
"wires": [
[
"b6774dd0.37dff"
]
]
},
{
"id": "40a8e016a768d4fa",
"type": "junction",
"z": "98c1572b.950998",
"x": 680,
"y": 320,
"wires": [
[
"2014e2ec.7cf63e"
]
]
},
{
"id": "d160eedb5f68eb47",
"type": "junction",
"z": "98c1572b.950998",
"x": 520,
"y": 200,
"wires": [
[
"85a06a9c.110828"
]
]
},
{
"id": "22818b50528c24cc",
"type": "junction",
"z": "98c1572b.950998",
"x": 500,
"y": 320,
"wires": [
[
"40a8e016a768d4fa"
]
]
},
{
"id": "b088b485.d767b8",
"type": "comment",
"z": "d6a9334c12c71996",
"name": "Smiling is always a good idea",
"info": "",
"x": 260,
"y": 70,
"wires": []
},
{
"id": "9202474a.8ed598",
"type": "do-return",
"z": "d6a9334c12c71996",
"name": "",
"mode": "done",
"saveValue": false,
"x": 520,
"y": 120,
"wires": []
},
{
"id": "54c489d1.9b8168",
"type": "change",
"z": "d6a9334c12c71996",
"name": "Smile",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "So many red balloons flying. Wow! :)",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 340,
"y": 120,
"wires": [
[
"9202474a.8ed598"
]
]
},
{
"id": "bfdf8ef2.7266a",
"type": "switch",
"z": "d6a9334c12c71996",
"name": "",
"property": "color",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "red",
"vt": "str"
},
{
"t": "eq",
"v": "blue",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 190,
"y": 120,
"wires": [
[
"54c489d1.9b8168"
],
[
"a477229f.34291"
]
]
},
{
"id": "a477229f.34291",
"type": "change",
"z": "d6a9334c12c71996",
"name": "Smile",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "So many lovely blue balloons. :)",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 340,
"y": 170,
"wires": [
[
"9202474a.8ed598"
]
]
},
{
"id": "18a66fd.9292f9",
"type": "do",
"z": "d9faa645.5bfcf8",
"name": "",
"tasks": [
"default"
],
"mode": "msg",
"each": "",
"eachType": "msg",
"yield": "keyValue",
"doneOutput": true,
"firstValueOutput": false,
"lastValueOutput": false,
"outputs": 2,
"_version": "0.4.1",
"x": 330,
"y": 130,
"wires": [
[
"c24065ab.7c41e8"
],
[
"6ae4c26e.7de8dc"
]
]
},
{
"id": "76ad755e.45063c",
"type": "do-return",
"z": "d9faa645.5bfcf8",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1020,
"y": 130,
"wires": []
},
{
"id": "61725a2d.4971a4",
"type": "debug",
"z": "d9faa645.5bfcf8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 790,
"y": 240,
"wires": []
},
{
"id": "c24065ab.7c41e8",
"type": "change",
"z": "d9faa645.5bfcf8",
"name": "puncture balloon :)",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "msg.payload - 1",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 130,
"wires": [
[
"d4063b53.69ee08"
]
]
},
{
"id": "bfd89a3a.160f88",
"type": "inject",
"z": "d9faa645.5bfcf8",
"name": "99 red balloons",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "99",
"payloadType": "num",
"x": 120,
"y": 130,
"wires": [
[
"18a66fd.9292f9"
]
]
},
{
"id": "d4063b53.69ee08",
"type": "switch",
"z": "d9faa645.5bfcf8",
"name": "more balloons?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 800,
"y": 130,
"wires": [
[
"76ad755e.45063c"
],
[
"8816b1c8.08343"
]
]
},
{
"id": "8816b1c8.08343",
"type": "do-return",
"z": "d9faa645.5bfcf8",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1010,
"y": 180,
"wires": []
},
{
"id": "6ae4c26e.7de8dc",
"type": "change",
"z": "d9faa645.5bfcf8",
"name": "no more balloons :(",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "That was fun! But now I already punctured all the balloons. :/ Do you have me some more?",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 240,
"wires": [
[
"61725a2d.4971a4"
]
]
},
{
"id": "4ac62b51.1d8d04",
"type": "comment",
"z": "d9faa645.5bfcf8",
"name": "Description of Loop-Example",
"info": "Loops are the most basic usecase for the do-return-nodes. Just drag the do-node onto the canvas and wire its first output (task output) to whatever shall be repeatedly done and the second output (done-output) to where the flow shall continue after the loop ended. Using the return node you can decide whether you want to execute the loop once again (continue mode) or to end it (done mode).",
"x": 160,
"y": 60,
"wires": []
},
{
"id": "8f4d8f31.7603d",
"type": "do",
"z": "8b50971b.a49d58",
"name": "",
"tasks": [
"Paint white",
"Let balloon fly",
"Smile"
],
"mode": "msg",
"each": "",
"eachType": "msg",
"yield": "keyValue",
"doneOutput": true,
"firstValueOutput": false,
"lastValueOutput": false,
"outputs": 4,
"_version": "0.4.1",
"x": 330,
"y": 130,
"wires": [
[
"7f3c80de.33b62"
],
[
"98e054a3.6efdb8"
],
[
"c87c123d.7a65a"
],
[
"42ab67d2.12a628"
]
]
},
{
"id": "3e77f475.9764ec",
"type": "do-return",
"z": "8b50971b.a49d58",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1020,
"y": 170,
"wires": []
},
{
"id": "94766e4b.0424c",
"type": "do-return",
"z": "8b50971b.a49d58",
"name": "",
"mode": "done",
"saveValue": false,
"x": 730,
"y": 270,
"wires": []
},
{
"id": "42ab67d2.12a628",
"type": "debug",
"z": "8b50971b.a49d58",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 570,
"y": 350,
"wires": []
},
{
"id": "c87c123d.7a65a",
"type": "change",
"z": "8b50971b.a49d58",
"name": "Smile",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "So many red balloons flying. Cool! :)",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 270,
"wires": [
[
"94766e4b.0424c"
]
]
},
{
"id": "48edc785.2d0098",
"type": "do-return",
"z": "8b50971b.a49d58",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1220,
"y": 90,
"wires": []
},
{
"id": "855c920c.14b34",
"type": "switch",
"z": "8b50971b.a49d58",
"name": "more balloons?",
"property": "current_balloon",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "$count(msg.payload) - 1",
"vt": "jsonata"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1000,
"y": 110,
"wires": [
[
"48edc785.2d0098"
],
[
"feeb0c66.b5931"
]
]
},
{
"id": "feeb0c66.b5931",
"type": "do-return",
"z": "8b50971b.a49d58",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1210,
"y": 130,
"wires": []
},
{
"id": "2db458ac.da41e8",
"type": "inject",
"z": "8b50971b.a49d58",
"name": "99 white balloons",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\"]",
"payloadType": "json",
"x": 120,
"y": 130,
"wires": [
[
"8f4d8f31.7603d"
]
]
},
{
"id": "3c51a9de.e0d7b6",
"type": "do-return",
"z": "8b50971b.a49d58",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1010,
"y": 210,
"wires": []
},
{
"id": "7f3c80de.33b62",
"type": "change",
"z": "8b50971b.a49d58",
"name": "next balloon",
"rules": [
{
"t": "set",
"p": "current_balloon",
"pt": "msg",
"to": "msg.current_balloon >= 0 ? msg.current_balloon + 1 : 0",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 570,
"y": 110,
"wires": [
[
"b65f5fea.ae4f2"
]
]
},
{
"id": "b65f5fea.ae4f2",
"type": "function",
"z": "8b50971b.a49d58",
"name": "paint red",
"func": "msg.payload[msg.current_balloon] = \"red\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 780,
"y": 110,
"wires": [
[
"855c920c.14b34"
]
]
},
{
"id": "98e054a3.6efdb8",
"type": "function",
"z": "8b50971b.a49d58",
"name": "let balloon fly",
"func": "msg.payload.pop();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 570,
"y": 180,
"wires": [
[
"4247a2da.af362c"
]
]
},
{
"id": "4247a2da.af362c",
"type": "switch",
"z": "8b50971b.a49d58",
"name": "more balloons?",
"property": "payload.length",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 800,
"y": 190,
"wires": [
[
"3e77f475.9764ec"
],
[
"3c51a9de.e0d7b6"
]
]
},
{
"id": "ae68f0e9.f06eb",
"type": "comment",
"z": "8b50971b.a49d58",
"name": "Description of Task-List-Example",
"info": "Like having a TODO-list, you can tell Node-RED to sequentially do some tasks (on the same message).\n\nTherefore you need to add more task-outputs in the do-node (by adding tasks in its configuration). Each time a return-node in done-mode is called, it returns to the do-node and continues with the next task. Returning in continue-mode loops the current task.",
"x": 180,
"y": 60,
"wires": []
},
{
"id": "123ed832.1535d8",
"type": "do",
"z": "19507521.e9188b",
"name": "",
"tasks": [
"Paint white",
"Let balloon fly",
"Smile"
],
"mode": "msg",
"each": "",
"eachType": "msg",
"yield": "keyValue",
"doneOutput": true,
"firstValueOutput": false,
"lastValueOutput": false,
"outputs": 4,
"_version": "0.4.1",
"x": 330,
"y": 160,
"wires": [
[
"a412c18f.0969"
],
[
"b5116b07.d4f558"
],
[
"69269666.b3e568"
],
[
"bec15721.0bbe08"
]
]
},
{
"id": "ca4d1582.7d2d28",
"type": "do-return",
"z": "19507521.e9188b",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1020,
"y": 200,
"wires": []
},
{
"id": "e4e96a79.50ae18",
"type": "do-return",
"z": "19507521.e9188b",
"name": "",
"mode": "done",
"saveValue": false,
"x": 730,
"y": 300,
"wires": []
},
{
"id": "bec15721.0bbe08",
"type": "debug",
"z": "19507521.e9188b",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 570,
"y": 380,
"wires": []
},
{
"id": "69269666.b3e568",
"type": "change",
"z": "19507521.e9188b",
"name": "Smile",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "I'm happy. :)",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 550,
"y": 300,
"wires": [
[
"e4e96a79.50ae18"
]
]
},
{
"id": "d525aa05.aedba8",
"type": "do-return",
"z": "19507521.e9188b",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1460,
"y": 120,
"wires": []
},
{
"id": "8c888461.8b43d8",
"type": "switch",
"z": "19507521.e9188b",
"name": "more balloons?",
"property": "current_balloon",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "$count(msg.payload) - 1",
"vt": "jsonata"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1240,
"y": 140,
"wires": [
[
"d525aa05.aedba8"
],
[
"3f6c10ce.42b8a"
]
]
},
{
"id": "3f6c10ce.42b8a",
"type": "do-return",
"z": "19507521.e9188b",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1450,
"y": 160,
"wires": []
},
{
"id": "7c26f69.4582008",
"type": "inject",
"z": "19507521.e9188b",
"name": "99 white balloons",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\"]",
"payloadType": "json",
"x": 120,
"y": 130,
"wires": [
[
"123ed832.1535d8"
]
]
},
{
"id": "648622b8.ebfc6c",
"type": "do-return",
"z": "19507521.e9188b",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1010,
"y": 240,
"wires": []
},
{
"id": "a412c18f.0969",
"type": "change",
"z": "19507521.e9188b",
"name": "next balloon",
"rules": [
{
"t": "set",
"p": "current_balloon",
"pt": "msg",
"to": "msg.current_balloon >= 0 ? msg.current_balloon + 1 : 0",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 570,
"y": 140,
"wires": [
[
"5beca763.a8e158"
]
]
},
{
"id": "92c6b2a5.119d3",
"type": "function",
"z": "19507521.e9188b",
"name": "paint red",
"func": "msg.payload[msg.current_balloon] = \"red\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1020,
"y": 140,
"wires": [
[
"8c888461.8b43d8"
]
]
},
{
"id": "b5116b07.d4f558",
"type": "function",
"z": "19507521.e9188b",
"name": "let balloon fly",
"func": "msg.payload.pop();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 570,
"y": 220,
"wires": [
[
"5d844cf5.4988d4"
]
]
},
{
"id": "5d844cf5.4988d4",
"type": "switch",
"z": "19507521.e9188b",
"name": "more balloons?",
"property": "payload.length",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 800,
"y": 220,
"wires": [
[
"ca4d1582.7d2d28"
],
[
"648622b8.ebfc6c"
]
]
},
{
"id": "a9ab10d2.3f354",
"type": "inject",
"z": "19507521.e9188b",
"name": "99 mixed balloons",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[\"white\",\"blue\",\"white\",\"green\",\"white\",\"white\",\"yellow\",\"yellow\",\"white\",\"red\",\"green\",\"white\",\"blue\",\"blue\",\"green\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"white\",\"red\",\"green\",\"white\",\"blue\",\"blue\",\"green\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"white\",\"white\",\"white\",\"white\",\"red\",\"green\",\"white\",\"blue\",\"blue\",\"green\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"white\",\"red\",\"green\",\"white\",\"blue\",\"white\",\"white\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"white\",\"red\",\"green\",\"white\",\"blue\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"green\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"white\",\"white\",\"green\",\"white\",\"yellow\",\"white\",\"red\",\"white\",\"yellow\",\"white\",\"red\",\"red\",\"white\",\"blue\",\"white\"]",
"payloadType": "json",
"x": 130,
"y": 190,
"wires": [
[
"123ed832.1535d8"
]
]
},
{
"id": "5beca763.a8e158",
"type": "switch",
"z": "19507521.e9188b",
"name": "is it red?",
"property": "current_balloon",
"propertyType": "msg",
"rules": [
{
"t": "jsonata_exp",
"v": "msg.payload[$$.msg.current_balloon] = \"red\"",
"vt": "jsonata"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 780,
"y": 140,
"wires": [
[
"43d17ee8.27433"
],
[
"92c6b2a5.119d3"
]
]
},
{
"id": "ae362cb9.358e4",
"type": "do-return",
"z": "19507521.e9188b",
"name": "",
"mode": "abort",
"saveValue": false,
"x": 1210,
"y": 90,
"wires": []
},
{
"id": "8cfe76f2.bc1158",
"type": "comment",
"z": "19507521.e9188b",
"name": "Description of Abort-Example",
"info": "You can abort a task-list at any time by returning in abort-mode.\n\nIn this example the balloons get painted red but in case a balloon is already red, it immediately aborts as this should not happen.",
"x": 160,
"y": 60,
"wires": []
},
{
"id": "43d17ee8.27433",
"type": "change",
"z": "19507521.e9188b",
"name": "Set error",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Abort: Balloon was already red.",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 90,
"wires": [
[
"ae362cb9.358e4"
]
]
},
{
"id": "febdb7e8.509a88",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1260,
"y": 300,
"wires": []
},
{
"id": "1ed9cd0.20b0733",
"type": "debug",
"z": "98c1572b.950998",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 570,
"y": 480,
"wires": []
},
{
"id": "49763f9.c5a2ac",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1420,
"y": 180,
"wires": []
},
{
"id": "a06ba5ae.b74748",
"type": "switch",
"z": "98c1572b.950998",
"name": "more balloons?",
"property": "current_balloon",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "$count(msg.payload) - 1",
"vt": "jsonata"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1200,
"y": 200,
"wires": [
[
"49763f9.c5a2ac"
],
[
"df3ee4f7.a5a2f8"
]
]
},
{
"id": "df3ee4f7.a5a2f8",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1410,
"y": 220,
"wires": []
},
{
"id": "2fcfafc.500b75",
"type": "inject",
"z": "98c1572b.950998",
"name": "Start",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 260,
"wires": [
[
"39cf6db8.ea8302"
]
]
},
{
"id": "ca97a02e.e109e",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1250,
"y": 340,
"wires": []
},
{
"id": "85a06a9c.110828",
"type": "change",
"z": "98c1572b.950998",
"name": "next balloon",
"rules": [
{
"t": "set",
"p": "current_balloon",
"pt": "msg",
"to": "msg.current_balloon >= 0 ? msg.current_balloon + 1 : 0",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 770,
"y": 200,
"wires": [
[
"d07a273e.cb1a38"
]
]
},
{
"id": "d07a273e.cb1a38",
"type": "function",
"z": "98c1572b.950998",
"name": "paint red",
"func": "msg.payload[msg.current_balloon] = \"red\";\nmsg.color = \"red\";\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 980,
"y": 200,
"wires": [
[
"a06ba5ae.b74748"
]
]
},
{
"id": "2014e2ec.7cf63e",
"type": "function",
"z": "98c1572b.950998",
"name": "let balloon fly",
"func": "msg.payload.pop();\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 810,
"y": 320,
"wires": [
[
"b3111487.4c41b8"
]
]
},
{
"id": "b3111487.4c41b8",
"type": "switch",
"z": "98c1572b.950998",
"name": "more balloons?",
"property": "payload.length",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "num"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1040,
"y": 320,
"wires": [
[
"febdb7e8.509a88"
],
[
"ca97a02e.e109e"
]
]
},
{
"id": "28668177.9e16de",
"type": "comment",
"z": "98c1572b.950998",
"name": "Description of Overlapping-Task-Lists-Example",
"info": "Using do-red, you can define different task-lists having some tasks in common. This allows to create e.g. some kind of building plan.\n\nSome tasks are thereby executed in both cases (e.g. creating the ballons) and some are specific for one building plan (e.g. how the ballons get colored or what to do with them afterwards).\n\nThe return node always knows to which do-node it needs to return to.\n\nIn this example we have two building plans: The first creates red ballons and lets them fly, the second creates blue balloons. Blue balloons are not meant for flying, so they are kept for Node-RED to be happy. ;)",
"x": 200,
"y": 180,
"wires": []
},
{
"id": "79e6cfc5.a8483",
"type": "comment",
"z": "98c1572b.950998",
"name": "We want red balloons",
"info": "",
"x": 800,
"y": 150,
"wires": []
},
{
"id": "b6774dd0.37dff",
"type": "change",
"z": "98c1572b.950998",
"name": "create 99 white ballons",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\",\"white\"]",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 800,
"y": 100,
"wires": [
[
"4ad3363.abb25c8"
]
]
},
{
"id": "3820b99.245ad46",
"type": "comment",
"z": "98c1572b.950998",
"name": "Create a bunch of balloons",
"info": "",
"x": 810,
"y": 50,
"wires": []
},
{
"id": "4ad3363.abb25c8",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1000,
"y": 100,
"wires": []
},
{
"id": "df7247b0.db8768",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "continue",
"saveValue": false,
"x": 1220,
"y": 680,
"wires": []
},
{
"id": "e769c079.86492",
"type": "switch",
"z": "98c1572b.950998",
"name": "more balloons?",
"property": "current_balloon",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "$count(msg.payload) - 1",
"vt": "jsonata"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1000,
"y": 700,
"wires": [
[
"df7247b0.db8768"
],
[
"aea3f92d.c221a8"
]
]
},
{
"id": "aea3f92d.c221a8",
"type": "do-return",
"z": "98c1572b.950998",
"name": "",
"mode": "done",
"saveValue": false,
"x": 1210,
"y": 720,
"wires": []
},
{
"id": "90ebbfb2.b2589",
"type": "change",
"z": "98c1572b.950998",
"name": "next balloon",
"rules": [
{
"t": "set",
"p": "current_balloon",
"pt": "msg",
"to": "msg.current_balloon >= 0 ? msg.current_balloon + 1 : 0",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 570,
"y": 700,
"wires": [
[
"926e8958.bb32f8"
]
]
},
{
"id": "926e8958.bb32f8",
"type": "function",
"z": "98c1572b.950998",
"name": "paint blue",
"func": "msg.payload[msg.current_balloon] = \"blue\";\nmsg.color = \"blue\";\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 780,
"y": 700,
"wires": [
[
"e769c079.86492"
]
]
},
{
"id": "a71eb74b.8fe2c8",
"type": "comment",
"z": "98c1572b.950998",
"name": "We want blue balloons",
"info": "",
"x": 600,
"y": 650,
"wires": []
},
{
"id": "555582c0.f5f6fc",
"type": "comment",
"z": "98c1572b.950998",
"name": "Let the balloons fly",
"info": "",
"x": 830,
"y": 280,
"wires": []
},
{
"id": "39cf6db8.ea8302",
"type": "do",
"z": "98c1572b.950998",
"name": "Create red balloons",
"tasks": [
"Create balloons",
"Paint them red",
"Let them fly",
"Smile"
],
"mode": "msg",
"each": "",
"eachType": "msg",
"yield": "keyValue",
"doneOutput": true,
"firstValueOutput": false,
"lastValueOutput": false,
"outputs": 5,
"_version": "0.4.1",
"x": 290,
"y": 260,
"wires": [
[
"cf738bbd1450c95f"
],
[
"d160eedb5f68eb47"
],
[
"22818b50528c24cc"
],
[
"f0938300cbe4c0b1"
],
[
"1ed9cd0.20b0733"
]
]
},
{
"id": "19ac8522.bc84db",
"type": "do",
"z": "98c1572b.950998",
"name": "Create blue balloons",
"tasks": [
"Create ballons",
"Paint them blue",
"Let them fily",
"Smile"
],
"mode": "msg",
"each": "",
"eachType": "msg",
"yield": "keyValue",
"doneOutput": true,
"firstValueOutput": false,
"lastValueOutput": false,
"outputs": 5,
"_version": "0.4.1",
"x": 300,
"y": 680,
"wires": [
[
"aa6fd69fe1bfadcb"
],
[
"90ebbfb2.b2589"
],
[
"22818b50528c24cc"
],
[
"b2b6755fc748e4dd"
],
[
"f0777923f509d532"
]
]
},
{
"id": "2ebeb21e.8bd6ae",
"type": "inject",
"z": "98c1572b.950998",
"name": "Start",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 90,
"y": 680,
"wires": [
[
"19ac8522.bc84db"
]
]
},
{
"id": "f0777923f509d532",
"type": "debug",
"z": "98c1572b.950998",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 570,
"y": 800,
"wires": []
},
{
"id": "aa6fd69fe1bfadcb",
"type": "link out",
"z": "98c1572b.950998",
"name": "go to create",
"mode": "link",
"links": [
"5e980dba095fa750"
],
"x": 570,
"y": 600,
"wires": [],
"l": true
},
{
"id": "5e980dba095fa750",
"type": "link in",
"z": "98c1572b.950998",
"name": "create",
"links": [
"aa6fd69fe1bfadcb",
"e08332501c9392f7"
],
"x": 370,
"y": 80,
"wires": [
[
"cf738bbd1450c95f"
]
],
"l": true
},
{
"id": "f0938300cbe4c0b1",
"type": "subflow:d6a9334c12c71996",
"z": "98c1572b.950998",
"name": "",
"x": 580,
"y": 420,
"wires": []
},
{
"id": "b2b6755fc748e4dd",
"type": "subflow:d6a9334c12c71996",
"z": "98c1572b.950998",
"name": "",
"x": 580,
"y": 760,
"wires": []
},
{
"id": "20e73f86289bfec6",
"type": "comment",
"z": "98c1572b.950998",
"name": "works also with subflows",
"info": "",
"x": 610,
"y": 380,
"wires": []
},
{
"id": "9f805e9c08470329",
"type": "inject",
"z": "a37ba4fb4c0f75b5",
"g": "13801fdd6b5b4fa2",
"name": "start",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 220,
"wires": [
[
"fa6c84b86112dacf"
]
]
},
{
"id": "bd3ea16681f75a48",
"type": "do",
"z": "a37ba4fb4c0f75b5",
"g": "13801fdd6b5b4fa2",
"name": "",
"tasks": [
"Task0",
"Task1"
],
"mode": "each",
"each": "balloons",
"eachType": "msg",
"yield": "value",
"doneOutput": true,
"firstValueOutput": false,
"lastValueOutput": false,
"outputs": 3,
"_version": "0.4.1",
"x": 460,
"y": 220,
"wires": [
[
"ec13c40821918014"
],
[
"e88ffe5ac5c0e1cc"
],
[
"c848fbb8bcf13c73"
]
]
},
{
"id": "6ed13f9be5e114b7",
"type": "debug",
"z": "a37ba4fb4c0f75b5",
"g": "13801fdd6b5b4fa2",
"name": "balloons :)",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",