[Example] Basic nodes flow4

Questions and Answers

Moderator: IoTStudio Support

Post Reply
IoTStudio Support
Posts: 39
Joined: Wed Nov 23, 2022 9:26 am

[Example] Basic nodes flow4

Post by IoTStudio Support »

This is basic nodes flow4 for IoT Studio try:

Code: Select all

[{"id":"41e2e7b968d1c6fd","type":"inject","z":"fa60de603bcf672a","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":100,"wires":[["b3c2a5074ca16049"]]},{"id":"b3c2a5074ca16049","type":"function","z":"fa60de603bcf672a","name":"increaing context variable of context 1","func":"var count = context.get('contextVar1') || 0;\ncount += 1;\ncontext.set('contextVar1', count);\nmsg.payload = count;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":100,"wires":[["27e6f764488bd658"]]},{"id":"27e6f764488bd658","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":100,"wires":[]},{"id":"98d4391b3972dc29","type":"inject","z":"fa60de603bcf672a","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":180,"wires":[["642281c45d4bbafa"]]},{"id":"4c305d856aa3a4a9","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":180,"wires":[]},{"id":"b27dae7664151216","type":"comment","z":"fa60de603bcf672a","name":"context variable example","info":"","x":350,"y":60,"wires":[]},{"id":"642281c45d4bbafa","type":"function","z":"fa60de603bcf672a","name":"increaing global variable of flow 3","func":"var count = context.global.get('globalVar1') || 0;\ncount += 1;\ncontext.global.set('globalVar1', count);\nmsg.payload = count;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":180,"wires":[["4c305d856aa3a4a9"]]},{"id":"065f05d620d5993b","type":"inject","z":"fa60de603bcf672a","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":320,"wires":[["2e23e4350f83cf4d"]]},{"id":"27929510838f972d","type":"inject","z":"fa60de603bcf672a","name":"just injection 1","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":330,"y":360,"wires":[["b05c08ae7b8ac6aa"]]},{"id":"548cc6a2ec10270e","type":"inject","z":"fa60de603bcf672a","name":"just injection 1","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":330,"y":400,"wires":[["5ecbfa8441cf22cf"]]},{"id":"b05c08ae7b8ac6aa","type":"function","z":"fa60de603bcf672a","name":"switch on","func":"msg.payload = true;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":360,"wires":[["2e23e4350f83cf4d"]]},{"id":"5ecbfa8441cf22cf","type":"function","z":"fa60de603bcf672a","name":"switch off","func":"msg.payload = false;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":400,"wires":[["2e23e4350f83cf4d"]]},{"id":"4f9444692aeb4ec6","type":"function","z":"fa60de603bcf672a","name":"print global increaing variable","func":"var theVar = context.global.get(\"globalVar1\");\n\nif (theVar == undefined) {\n    msg.payload = \"this variable is undefined\";\n} else {\n    msg.payload = \"this variable is \" + theVar;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":320,"wires":[["12a23cede8116f26"]]},{"id":"12a23cede8116f26","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":320,"wires":[]},{"id":"60bbbc9521e33221","type":"comment","z":"fa60de603bcf672a","name":"cycle time example (with switch)","info":"","x":370,"y":280,"wires":[]},{"id":"5a1fc6cc3c9c2dae","type":"inject","z":"fa60de603bcf672a","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":140,"wires":[["085fc753a7d93716"]]},{"id":"085fc753a7d93716","type":"function","z":"fa60de603bcf672a","name":"increaing context variable of context 2","func":"var count = context.get('contextVar2') || 0;\ncount += 1;\ncontext.set('contextVar2', count);\nmsg.payload = count;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":140,"wires":[["72974b6d8c683133"]]},{"id":"72974b6d8c683133","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":140,"wires":[]},{"id":"59175c39a2db9975","type":"inject","z":"fa60de603bcf672a","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":220,"wires":[["80bec1adf2759deb"]]},{"id":"392d8ba0c03eed10","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":220,"wires":[]},{"id":"80bec1adf2759deb","type":"function","z":"fa60de603bcf672a","name":"increaing global variable of flow 4","func":"var count = context.global.get('globalVar2') || 0;\ncount += 1;\ncontext.global.set('globalVar2', count);\nmsg.payload = count;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":220,"wires":[["392d8ba0c03eed10"]]},{"id":"2e23e4350f83cf4d","type":"function","z":"fa60de603bcf672a","name":"Function Switch","func":"if (msg.payload != undefined) {\n    context.set('switch', msg.payload);\n}\n\nif (context.get('switch')) {\n    return msg;\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":320,"wires":[["4f9444692aeb4ec6"]]}]
Best Regards,
IoT Studio Support Team
Post Reply