External Settings - cflurin/node-red-contrib-dsm GitHub Wiki
dsm to read settings from an external file:
[{"id":"b5583107.705f7","type":"dsm","z":"ac4aa9f6.c24288","name":"external settings","sm_config":"{\n \"currentState\": \"idle\",\n \"states\": {\n \"idle\": {\n \"start\": \"reading\"\n },\n \"reading\": {\n \"done\": \"idle\"\n }\n },\n \"data\": {\n \"ext_file\": \"ext_settings.json\"\n },\n \"methods\": {\n \"init\": [\n \"sm.fs = require('fs');\",\n \"sm.udir = RED.settings.userDir + '/';\"\n ],\n \"start\": [\n \"sm.fs.readFile(sm.udir + sm.data.ext_file, 'utf8', function(err, data) {\",\n \"if (err) {\",\n \"node.error(err);\",\n \"} else {\",\n \"var ext_settings = JSON.parse(data);\",\n \"global.set('ext_settings', ext_settings);\",\n \"msg.payload = ext_settings;\",\n \"resume('done', msg);\",\n \"};\",\n \"});\",\n \"output = false;\"\n ],\n \"done\": [\n \"sm.fill = 'green';\",\n \"sm.text = 'done';\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.fill\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"sm.text\"\n }\n }\n }\n}","x":770,"y":300,"wires":["311049db.f64e26"](/cflurin/node-red-contrib-dsm/wiki/"311049db.f64e26")},{"id":"4fb989b1.fe0ae8","type":"inject","z":"ac4aa9f6.c24288","name":"","topic":"start","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":560,"y":300,"wires":["b5583107.705f7"](/cflurin/node-red-contrib-dsm/wiki/"b5583107.705f7")},{"id":"311049db.f64e26","type":"debug","z":"ac4aa9f6.c24288","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":300,"wires":[]}]