mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
1 line
1.7 KiB
JSON
1 line
1.7 KiB
JSON
|
[{"id":"3ece1efd.306c22","type":"inject","z":"1b8d1c9a.2dae03","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":120,"wires":[["c9100743.673598"]]},{"id":"ed3da95d.62ee98","type":"debug","z":"1b8d1c9a.2dae03","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":120,"wires":[]},{"id":"85b5b8ad.0717d8","type":"comment","z":"1b8d1c9a.2dae03","name":"using external modules\\n(needs change in settings.js - see details on node description of this node) ","info":"The function node can use external node modules using global context value.\n\nAdditional node modules must be loaded in `settings.js` file and added to the `functionGlobalContext` property. \n\nFor example, following definition in `settings.js` load `os` module on start up of Node-RED. \n\n```\nfunctionGlobalContext: {\n os: require(\"os\")\n}\n```\n\nThe `os` module can be accessed in a function blocks as:\n```\nglobal.get(\"os\")\n```\n\nSee Node-RED user guide about [functions](https://nodered.org/docs/user-guide/writing-functions) and [context store](https://nodered.org/docs/user-guide/context).","x":320,"y":60,"wires":[]},{"id":"c9100743.673598","type":"function","z":"1b8d1c9a.2dae03","name":"use os module","func":"// use external os module to access OS information\nvar os = global.get(\"os\");\nmsg.payload = { \n hostname: os.hostname(),\n arch: os.arch(),\n platform: os.platform(),\n release: os.release(),\n free: os.freemem()\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":120,"wires":[["ed3da95d.62ee98"]]}]
|