[Example] Basic nodes flow3

Questions and Answers

Moderator: IoTStudio Support

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

[Example] Basic nodes flow3

Post by IoTStudio Support »

This is basic nodes flows for IoT Studio try:

Code: Select all

[{"id":"41e2e7b968d1c6fd","type":"inject","z":"fa60de603bcf672a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":260,"wires":[["b3c2a5074ca16049"]]},{"id":"b3c2a5074ca16049","type":"function","z":"fa60de603bcf672a","name":"save global variable (111)","func":"global.set(\"globalVar1\", 111);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":260,"wires":[["27e6f764488bd658"]]},{"id":"27e6f764488bd658","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":260,"wires":[]},{"id":"98d4391b3972dc29","type":"inject","z":"fa60de603bcf672a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":300,"wires":[["642281c45d4bbafa"]]},{"id":"4c305d856aa3a4a9","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":300,"wires":[]},{"id":"dc1a262f54b01cb8","type":"inject","z":"fa60de603bcf672a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":340,"wires":[["2b6cc24289ec3072"]]},{"id":"2b6cc24289ec3072","type":"function","z":"fa60de603bcf672a","name":"read global variable","func":"msg.payload = global.get('globalVar1');\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":340,"wires":[["0eac84aa0ea37ee8"]]},{"id":"0eac84aa0ea37ee8","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":340,"wires":[]},{"id":"1f6272e8579bf6a3","type":"inject","z":"fa60de603bcf672a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":380,"wires":[["51725ec517c6c0cb"]]},{"id":"51725ec517c6c0cb","type":"function","z":"fa60de603bcf672a","name":"remove a given global variable","func":"global.set('globalVar1');\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":380,"wires":[["db31457e51f95439"]]},{"id":"db31457e51f95439","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":380,"wires":[]},{"id":"b27dae7664151216","type":"comment","z":"fa60de603bcf672a","name":"global variable example","info":"","x":360,"y":220,"wires":[]},{"id":"642281c45d4bbafa","type":"function","z":"fa60de603bcf672a","name":"save global variable (abc)","func":"global.set(\"globalVar2\", 111);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":300,"wires":[["4c305d856aa3a4a9"]]},{"id":"b21e4c41709479dc","type":"inject","z":"fa60de603bcf672a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":420,"wires":[["f730abfe6e315fba"]]},{"id":"f730abfe6e315fba","type":"function","z":"fa60de603bcf672a","name":"remove global variables","func":"var keys = global.keys();\nfor (var i = 0; i < keys.length; i++) {\n    global.set(keys[i]);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":420,"wires":[["4ecd92e9c9956bcf"]]},{"id":"4ecd92e9c9956bcf","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":420,"wires":[]},{"id":"065f05d620d5993b","type":"inject","z":"fa60de603bcf672a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":460,"wires":[["ee7f5538eb5156b1"]]},{"id":"ee7f5538eb5156b1","type":"function","z":"fa60de603bcf672a","name":"check if undefined","func":"var theVar = 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":530,"y":460,"wires":[["3d8d3ba2a7bff0ba"]]},{"id":"3d8d3ba2a7bff0ba","type":"debug","z":"fa60de603bcf672a","name":"msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":460,"wires":[]}]
Best Regards,
IoT Studio Support Team
Post Reply