Created
September 4, 2022 18:45
-
-
Save hovissimo/86215f71c8649f01dc4bbcee4abde287 to your computer and use it in GitHub Desktop.
Node-RED simple modulo router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "211d2ade5b37281c", | |
"type": "function", | |
"z": "0d3a28192a31e0f9", | |
"name": "mod router", | |
"func": "const count = context.get('count') ?? 0;\n\nif (count < 5) {\n context.set('count', count + 1);\n return [msg, undefined];\n} else {\n context.set('count', 0);\n return [undefined, msg];\n}", | |
"outputs": 2, | |
"noerr": 0, | |
"initialize": "// Code added here will be run once\n// whenever the node is started.\ncontext.set('count', 0)", | |
"finalize": "", | |
"libs": [], | |
"x": 350, | |
"y": 1580, | |
"wires": [ | |
[ | |
"8c99127f924988c2" | |
], | |
[ | |
"3e8856a0f238788f" | |
] | |
] | |
}, | |
{ | |
"id": "16fd6d33980cf2c3", | |
"type": "inject", | |
"z": "0d3a28192a31e0f9", | |
"name": "", | |
"props": [ | |
{ | |
"p": "payload" | |
}, | |
{ | |
"p": "topic", | |
"vt": "str" | |
} | |
], | |
"repeat": "", | |
"crontab": "", | |
"once": false, | |
"onceDelay": 0.1, | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"x": 140, | |
"y": 1580, | |
"wires": [ | |
[ | |
"211d2ade5b37281c" | |
] | |
] | |
}, | |
{ | |
"id": "8c99127f924988c2", | |
"type": "debug", | |
"z": "0d3a28192a31e0f9", | |
"name": "main output", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 610, | |
"y": 1540, | |
"wires": [] | |
}, | |
{ | |
"id": "3e8856a0f238788f", | |
"type": "debug", | |
"z": "0d3a28192a31e0f9", | |
"name": "secondary output", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "payload", | |
"targetType": "msg", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 630, | |
"y": 1600, | |
"wires": [] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment