Hi all I new to node-red and I trying to toggle the output on my rpi.
I found the dsm node and the Blinking example which does everything I want, and here's the but, I'd like to bring the the variables to the dashboard so the user can change the "on_time" and off_time". I'm not sure how to do this or if it's possible, any help would be appreciate. Tks
"data": {
"on": 1,
"off": 0,
"on_time": 1000,
"off_time": 1000,
"blinks": 3,
"count": 0
},
[{"id":"93729166.52a7e","type":"debug","z":"6ff0723.8c6b78c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":900,"wires":[]},{"id":"e1a5ebe3.6c6df8","type":"inject","z":"6ff0723.8c6b78c","name":"","topic":"start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":880,"wires":[["ee084f39.d0118"]]},{"id":"ee084f39.d0118","type":"dsm","z":"6ff0723.8c6b78c","name":"blinking","sm_config":"{\n \"currentState\": \"idle\",\n \"states\": {\n \"idle\": {\n \"start\": \"on\",\n \"stop\": \"idle\"\n },\n \"on\": {\n \"turn_off\": \"off\",\n \"stop\": \"idle\"\n },\n \"off\": {\n \"turn_on\": \"on\",\n \"stop\": \"idle\"\n }\n },\n \"data\": {\n \"on\": 1,\n \"off\": 0,\n \"on_time\": 1000,\n \"off_time\": 1000,\n \"blinks\": 3,\n \"count\": 0\n },\n \"methods\": {\n \"init\": [\n \"sm.schedule = function(tran, delay, msg) {\",\n \" timeout.id = setTimeout(function() {\",\n \" resume(tran, msg)\",\n \" },delay);\",\n \"};\",\n \"sta.fill = 'grey';\"\n ],\n \"onBeforeTransition\": [\n \"if (!msg.topic) msg.topic = 'start';\",\n \"if (msg.blinks) sm.data.blinks = msg.blinks;\",\n \"if (msg.on_time) sm.data.on_time = msg.on_time;\",\n \"if (msg.off_time) sm.data.off_time = msg.off_time;\"\n ],\n \"start\": [\n \"sm.data.count = sm.data.blinks;\",\n \"resume('turn_on', msg);\",\n \"output = false;\"\n ],\n \"turn_on\": [\n \"if (sm.data.count) {\",\n \" sm.schedule('turn_off', sm.data.on_time, msg);\",\n \" if(sm.data.blinks !== 'continuing') sm.data.count--;\",\n \" sm.fill = 'yellow';\",\n \" msg.payload = sm.data.on;\",\n \" output = true;\",\n \"} else {\",\n \" sm.currentState = 'idle';\",\n \" sm.fill = 'grey';\",\n \" output = false;\",\n \"}\"\n ],\n \"turn_off\": [\n \"sm.schedule('turn_on', sm.data.off_time, msg);\",\n \"sm.fill = 'blue';\",\n \"msg.payload = sm.data.off;\"\n ],\n \"stop\": [\n \"clearTimeout(timeout.id);\",\n \"sm.fill = 'grey';\",\n \"msg.payload = sm.data.off;\"\n ],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.fill;\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"sm.currentState;\"\n }\n }\n }\n}","x":270,"y":900,"wires":[["93729166.52a7e"]]},{"id":"1ccae227.b1b73e","type":"inject","z":"6ff0723.8c6b78c","name":"","topic":"stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":920,"wires":[["ee084f39.d0118"]]}]