# Help with bringing variables to dashboard for Blinking example

**URL:** <https://discourse.nodered.org/t/help-with-bringing-variables-to-dashboard-for-blinking-example/20337>\
**Category:** General\
**Created:** [14 January 2020 20:45 UTC](https://discourse.nodered.org/t/help-with-bringing-variables-to-dashboard-for-blinking-example/20337 "2020-01-14T20:45:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Argus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/argus/32/16156_2.png) [@Argus](https://discourse.nodered.org/u/Argus)\
**Post date:** [14 January 2020 20:45 UTC](https://discourse.nodered.org/t/help-with-bringing-variables-to-dashboard-for-blinking-example/20337/1 "2020-01-14T20:45:57Z")

</div>

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](https://github.com/cflurin/node-red-contrib-dsm/wiki/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  
},

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![Argus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/argus/32/16156_2.png) [@Argus](https://discourse.nodered.org/u/Argus)\
**Post date:** [22 January 2020 19:16 UTC](https://discourse.nodered.org/t/help-with-bringing-variables-to-dashboard-for-blinking-example/20337/2 "2020-01-22T19:16:29Z")

</div>

Not Pretty but I think I figured it out.

```auto
[{"id":"7f79a8fd.2964d8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"15de926c.a6276e","type":"dsm","z":"7f79a8fd.2964d8","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\": 2000,\n \"off_time\": 2000,\n \"blinks\": \"continuing\",\n \"count\": 0\n },\n \"methods\": {\n \n \"setOn\": [\n\t\t\"sm.data.on_time = msg.payload;\",\n\t\t\"sm.fill = 'blue';\",\n\t\t\"sm.text = 'On time = '+sm.data.on;\"\n\t\t],\n\t\t\"setOff\": [\n\t\t\"sm.data.off_time = msg.payload;\",\n\t\t\"sm.fill = 'purple';\"\n\t\t],\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 = 'green';\",\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 = 'red';\",\n \"msg.payload = sm.data.off;\"\n],\n \"stop\": [\n \"clearTimeout(timeout.id);\",\n \"sm.fill = 'red';\",\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":650,"y":180,"wires":[["6e46e088.4c61e","b6e8bc91.7c6fa"]]},{"id":"d148b62b.d7e6e8","type":"inject","z":"7f79a8fd.2964d8","name":"","topic":"stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":200,"wires":[["15de926c.a6276e"]]},{"id":"43ae195d.c4c308","type":"inject","z":"7f79a8fd.2964d8","name":"","topic":"start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":160,"wires":[["15de926c.a6276e"]]},{"id":"68e4a3c4.75788c","type":"ui_button","z":"7f79a8fd.2964d8","name":"","group":"d3b84d8a.cd4","order":0,"width":"1","height":"1","passthru":false,"label":"On","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"start","x":430,"y":60,"wires":[["15de926c.a6276e"]]},{"id":"d7114920.d12518","type":"ui_button","z":"7f79a8fd.2964d8","name":"","group":"d3b84d8a.cd4","order":0,"width":"1","height":"1","passthru":false,"label":"Off","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"stop","x":430,"y":100,"wires":[["15de926c.a6276e"]]},{"id":"6e46e088.4c61e","type":"ui_chart","z":"7f79a8fd.2964d8","name":"","group":"d3b84d8a.cd4","order":0,"width":"4","height":"3","label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":810,"y":180,"wires":[[],[]]},{"id":"513fcd8e.70b674","type":"ui_text_input","z":"7f79a8fd.2964d8","name":"","label":"On Time","group":"d3b84d8a.cd4","order":0,"width":"2","height":"1","passthru":true,"mode":"text","delay":"0","topic":"setOn","x":140,"y":280,"wires":[["5c91c76a.f04518"]]},{"id":"c37f104f.c10e3","type":"ui_text_input","z":"7f79a8fd.2964d8","name":"","label":"Off Time","group":"d3b84d8a.cd4","order":0,"width":"2","height":"1","passthru":true,"mode":"text","delay":"0","topic":"setOff","x":140,"y":340,"wires":[["5c0158eb.d17cd8"]]},{"id":"b23cab66.3b6848","type":"function","z":"7f79a8fd.2964d8","name":"","func":"msg.payload *= 60000;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":280,"wires":[["15de926c.a6276e"]]},{"id":"5c91c76a.f04518","type":"change","z":"7f79a8fd.2964d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":280,"wires":[["b23cab66.3b6848"]]},{"id":"596dbd3e.5c8094","type":"function","z":"7f79a8fd.2964d8","name":"","func":"msg.payload *= 60000;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":340,"wires":[["15de926c.a6276e"]]},{"id":"5c0158eb.d17cd8","type":"change","z":"7f79a8fd.2964d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":340,"wires":[["596dbd3e.5c8094"]]},{"id":"b6e8bc91.7c6fa","type":"rpi-gpio out","z":"7f79a8fd.2964d8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":820,"y":140,"wires":[]},{"id":"d3b84d8a.cd4","type":"ui_group","z":"","name":"Group 5","tab":"7bc03c24.5ef4a4","order":5,"disp":true,"width":"6","collapse":false},{"id":"7bc03c24.5ef4a4","type":"ui_tab","z":"","name":"Automated Controls","icon":"fa-cogs"}]

```
