Node RED flows

(continuation of the “Node RED” article from the main page)

“Three Buttons”

The “Three Buttons” Flow follows the idea of having 3 different buttons generating a tweet with statistics of how many times that button has been pushed by visitors so far. This showcases the possibility of hooking up very basic buttons (or other “things”) to the internet.

The statistics are logged and backed via “Dweet” (LINK: http://dweet.io/) as an array of numbers. “Dweet” is in essence a twitter service for IoT machines where you can send information to and from IoT devices and platforms. We could just as well have used Twitter for the same functionality, but that would have resulted in having a twitter account tweeting numbers and codes after every button push. We therefore opted to use Dweet to “hide” these messages from Social Media.

For troubleshooting purposes we included virtual buttons to start, reset and read the current status of the Dweet array.

After every button push has been processed an actual tweet is then sent out on twitter.com/buttonspace_org with the detailed statistics and a short sentence.

Additionally MIDI Notes are generated from each button push and sent to a synthesizer which generates sounds in the exhibition room.

You can find the full code of our flow below.

 

“Switchboard”

The “Switchboard” Flow is the very heart of Buttonspace. Many different inputs and outputs come together which are then randomly or semi-randomly sent to a set of outputs.

On the input side you find all the buttons, here configured as GPIO Nodes since they are connected to the Raspberry Pi’s GPIO Pins, plus a Twitter node which searches twitter for all new tweets containing “@buttonspace_org” and “#catandmousegame”.

As a precaution we limited the amount of times any button can trigger an output to once every 3 seconds.

The inputs are then sent to a function node labeled “roll the dice”. In there a random output gets selected each an button or specified twitter mention is triggered.

On the output side we have a sound nodes with preprogrammed sounds like a doorbell or an elephant, Twitter nodes sending a random twitter message on twitter.com/buttonspace_org, a trigger that activates a WIFI controlled power socket, which turns a light on and off for a short duration.

Additionally each output connected to a MIDI note, which are sent to a synthesizer which generates sounds in the exhibition space.

As you can see the flow is open enough to accept any sort of input and to connect any sort of output, the only criteria currently being wheter such a “node” exists in Node RED. This allows us to easily add more in and outputs in the near future.

 

Flow “Three Buttons”

[{“id”:”2f0a4817.bfd318″,”type”:”tab”,”label”:”Intro”,”disabled”:false,”info”:””},{“id”:”c2f0fed8.d0d04″,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:”Red (0)”,”topic”:””,”payload”:”0″,”payloadType”:”num”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:””,”x”:370,”y”:260,”wires”:[[“d965cd49.ad426”]]},{“id”:”55544b92.7a4884″,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:”Green (1)”,”topic”:””,”payload”:”1″,”payloadType”:”num”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:””,”x”:380,”y”:300,”wires”:[[“d965cd49.ad426”]]},{“id”:”53c6e37e.66b1cc”,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Process Dweet”,”func”:”// save selection\nmsg.selection = msg.payload;\n\n\n// initialise the array if it does not exist\nvar array = flow.get(‘array’) || [0,0,0,0];\n\n// Set button names\nvar buttons = [\”blue\”,\”red\”,\”green\”,\”gray\”];\n\n// Set time string\nvar currentdate = new Date(); \nvar datetime = currentdate.getDate() + \”/\” + (currentdate.getMonth()+1)  + \”/\” + currentdate.getFullYear() + \” – \” + currentdate.getHours() + \”:\” + currentdate.getMinutes() + \”:\” + currentdate.getSeconds();\n\n\n// Update button count\narray[msg.payload] += 1;\nflow.set(\”array\”,array);\n\n//return data\nmsg.payload = array;\nmsg.array = array;\nmsg.payload = { \”Status\” : msg.payload };\n\n// Dweet Data\nmsg.thing = \”0fe098e1-c9fd-40e8-883e-bb62b4fa1556-asdf\”;\nmsg.type = \”POST\”;\nmsg.url = \”https://dweet.io:443/dweet/for/\” + msg.thing;\nmsg.headers = {\”Content-Type\” : \”application/json\”};\n\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:760,”y”:320,”wires”:[[“6d243c9f.e4a234″,”9cc76a75.e6b5e8”]]},{“id”:”862eb34b.cdb52″,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:””,”topic”:””,”payload”:””,”payloadType”:”date”,”repeat”:””,”crontab”:””,”once”:true,”x”:390,”y”:100,”wires”:[[“6c0d0ecf.7c96f”]]},{“id”:”d965cd49.ad426″,”type”:”delay”,”z”:”2f0a4817.bfd318″,”name”:””,”pauseType”:”rate”,”timeout”:”1″,”timeoutUnits”:”seconds”,”rate”:”1″,”nbRateUnits”:”1″,”rateUnits”:”second”,”randomFirst”:”1″,”randomLast”:”5″,”randomUnits”:”seconds”,”drop”:true,”x”:590,”y”:320,”wires”:[[“53c6e37e.66b1cc”]]},{“id”:”b3f112b2.fcd7b”,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:”Blue (2)”,”topic”:””,”payload”:”2″,”payloadType”:”num”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:””,”x”:370,”y”:340,”wires”:[[“d965cd49.ad426”]]},{“id”:”9f1a95c5.623268″,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:”Black (3)”,”topic”:””,”payload”:”3″,”payloadType”:”num”,”repeat”:”57600″,”crontab”:””,”once”:false,”onceDelay”:””,”x”:390,”y”:380,”wires”:[[“d965cd49.ad426”]]},{“id”:”6d243c9f.e4a234″,”type”:”http request”,”z”:”2f0a4817.bfd318″,”name”:””,”method”:”POST”,”ret”:”txt”,”url”:””,”tls”:””,”x”:990,”y”:320,”wires”:[[]]},{“id”:”6c0d0ecf.7c96f”,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Dweet”,”func”:”\nmsg.thing = \”0fe098e1-c9fd-40e8-883e-bb62b4fa1556-asdf\”;\n\nmsg.type = \”GET\”;\n\nmsg.url = \”https://dweet.io:443/get/latest/dweet/for/\” + msg.thing;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:610,”y”:100,”wires”:[[“7fe4050a.c0b7dc”]]},{“id”:”7fe4050a.c0b7dc”,”type”:”http request”,”z”:”2f0a4817.bfd318″,”name”:””,”method”:”GET”,”ret”:”obj”,”url”:””,”tls”:””,”x”:790,”y”:100,”wires”:[[“c3cd8ca5.d7fc4”]]},{“id”:”c3cd8ca5.d7fc4″,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Initiate”,”func”:”var array = msg.payload[‘with’][‘0’][‘content’][‘Status’];\n\nflow.set(‘array’,array);\n\nmsg.payload = array;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:950,”y”:100,”wires”:[[]]},{“id”:”413d4803.c676e8″,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:””,”topic”:””,”payload”:”Request Dweet object”,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”x”:420,”y”:180,”wires”:[[“33946f90.fc7cb”]]},{“id”:”33946f90.fc7cb”,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Dweet”,”func”:”\nmsg.thing = \”0fe098e1-c9fd-40e8-883e-bb62b4fa1556-asdf\”;\n\nmsg.type = \”GET\”;\n\nmsg.url = \”https://dweet.io:443/get/latest/dweet/for/\” + msg.thing;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:610,”y”:180,”wires”:[[“b1be9781.d20168”]]},{“id”:”b1be9781.d20168″,”type”:”http request”,”z”:”2f0a4817.bfd318″,”name”:””,”method”:”GET”,”ret”:”obj”,”url”:””,”tls”:””,”x”:790,”y”:180,”wires”:[[“1283c372.4a769d”]]},{“id”:”9cc76a75.e6b5e8″,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Process Tweet”,”func”:”\n// Define and assign variables\nvar array = msg.array;\nvar buttons = [\”red\”,\”green\”,\”blue\”,\”black\”];\n\nvar tweets = [0,1,2,3,4,5,6,7];\n\ntweets[0] = [\”Carpe diem! You belong to the \”];\ntweets[1] = [\” buttonspace visitors who are enjoying a good day.\”];\ntweets[2] = [\”Cash money! You belong to the \”];\ntweets[3] = [\” buttonspace visitors that pushed for 1 billion dollars. Unfortunately this is not a cash machine.\”];\ntweets[4] = [\”Yes friend! You belong to the \”];\ntweets[5] = [\” buttonspace visitors that wish for world peace.\”];\ntweets[6] = [\”Oh oh! You belong to the \”];\ntweets[7] = [\” buttonspace visitors who found the button of infinite destruction.\”];\n\nvar texta = msg.selection * 2;\nvar textb = msg.selection * 2 + 1;\n\n// Create tweet\nvar summe = array[0] + array[1] + array[2] + array[3];\n//var tweet = \”You have pressed the \” + buttons[msg.selection] + \” button, like \” + Math.round(100*array[msg.selection]/summe) + \”% of the \” + summe + \” people who have pressed a button so far.\”;\n//var tweet = \”The \” + buttons[msg.selection] + \” button was pressed! This was the choice of \” + Math.round(100*array[msg.selection]/summe) + \”% of the \” + summe + \” button space visitors.\”;\nvar tweet = tweets[texta] + Math.round(100*array[msg.selection]/summe) + \” percent of the \” + summe + tweets[textb];\n\nmsg.payload = tweet;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:760,”y”:400,”wires”:[[“7edff2f5.e9394c”,”7c4eda7a.766e64″]]},{“id”:”7edff2f5.e9394c”,”type”:”twitter out”,”z”:”2f0a4817.bfd318″,”twitter”:””,”name”:”Tweet”,”x”:970,”y”:400,”wires”:[]},{“id”:”ff24744d.13cce8″,”type”:”rpi-gpio in”,”z”:”2f0a4817.bfd318″,”name”:”Button RED”,”pin”:”7″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:350,”y”:500,”wires”:[[“71cb7794.487c28”]]},{“id”:”99169f8b.8a9c1″,”type”:”rpi-gpio in”,”z”:”2f0a4817.bfd318″,”name”:”Button GREEN”,”pin”:”29″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:360,”y”:540,”wires”:[[“bfc86c2d.1617c”]]},{“id”:”189902fa.c1567d”,”type”:”rpi-gpio in”,”z”:”2f0a4817.bfd318″,”name”:”Button BLUE”,”pin”:”31″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:350,”y”:580,”wires”:[[“c9a0a2ed.debbd”]]},{“id”:”5c8e78b5.6dd2b8″,”type”:”rpi-gpio in”,”z”:”2f0a4817.bfd318″,”name”:”Button BLACK”,”pin”:”32″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:350,”y”:620,”wires”:[[“9766776b.dc8c48”]]},{“id”:”71cb7794.487c28″,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”0″,”op2″:””,”op1type”:”num”,”op2type”:”nul”,”duration”:”250″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Red”,”x”:510,”y”:500,”wires”:[[“d965cd49.ad426″,”56e16f42.4b6a9”]]},{“id”:”bfc86c2d.1617c”,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”1″,”op2″:””,”op1type”:”num”,”op2type”:”nul”,”duration”:”250″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Green”,”x”:510,”y”:540,”wires”:[[“d965cd49.ad426″,”59337b95.ffd104”]]},{“id”:”c9a0a2ed.debbd”,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”2″,”op2″:””,”op1type”:”num”,”op2type”:”nul”,”duration”:”250″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Blue”,”x”:510,”y”:580,”wires”:[[“d965cd49.ad426″,”4dad2ac1.3cb674”]]},{“id”:”9766776b.dc8c48″,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”3″,”op2″:””,”op1type”:”num”,”op2type”:”nul”,”duration”:”250″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Black”,”x”:510,”y”:620,”wires”:[[“d965cd49.ad426″,”b5c7d3c9.e0e81”]]},{“id”:”65432371.26c64c”,”type”:”inject”,”z”:”2f0a4817.bfd318″,”name”:”Reset”,”topic”:””,”payload”:”Reset now”,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:370,”y”:140,”wires”:[[“ac0fb749.4bfc98″]],”outputLabels”:[“reset”]},{“id”:”ac0fb749.4bfc98″,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Reset”,”func”:”\nvar array = [0,0,0,0];\n\nflow.set(‘array’,array);\n\nmsg.payload = array;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:610,”y”:140,”wires”:[[]]},{“id”:”93bd9950.30d9e8″,”type”:”comment”,”z”:”2f0a4817.bfd318″,”name”:”Initialisiert array as Dweet”,”info”:””,”x”:150,”y”:100,”wires”:[]},{“id”:”f9f98730.32a258″,”type”:”comment”,”z”:”2f0a4817.bfd318″,”name”:”Setzt array auf 0 zurück”,”info”:””,”x”:150,”y”:140,”wires”:[]},{“id”:”c1ab848d.6c9478″,”type”:”comment”,”z”:”2f0a4817.bfd318″,”name”:”Zeigt Dweet Objekt”,”info”:””,”x”:130,”y”:180,”wires”:[]},{“id”:”6081ed5a.2f5874″,”type”:”comment”,”z”:”2f0a4817.bfd318″,”name”:”Hält Dweet Objekt am Leben”,”info”:””,”x”:160,”y”:380,”wires”:[]},{“id”:”57b31284.5586ac”,”type”:”comment”,”z”:”2f0a4817.bfd318″,”name”:”Virtuelle Knöpfe”,”info”:””,”x”:120,”y”:300,”wires”:[]},{“id”:”e2c7b314.4b0d9″,”type”:”comment”,”z”:”2f0a4817.bfd318″,”name”:”Physische Knöpfe”,”info”:””,”x”:130,”y”:560,”wires”:[]},{“id”:”1283c372.4a769d”,”type”:”function”,”z”:”2f0a4817.bfd318″,”name”:”Initiate”,”func”:”var array = msg.payload[‘with’][‘0’][‘content’][‘Status’];\n\n//flow.set(‘array’,array);\n\nmsg.payload = array;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:950,”y”:180,”wires”:[[“9625bfb1.93484”]]},{“id”:”9625bfb1.93484″,”type”:”debug”,”z”:”2f0a4817.bfd318″,”name”:””,”active”:true,”console”:false,”complete”:”false”,”x”:1150,”y”:180,”wires”:[]},{“id”:”ab19fe4b.1189c”,”type”:”midi out”,”z”:”2f0a4817.bfd318″,”name”:””,”midiport”:”1″,”x”:1020,”y”:560,”wires”:[]},{“id”:”59337b95.ffd104″,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”[144, 90, 120]”,”op2″:”[128, 90, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”300″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Ton grün”,”x”:760,”y”:540,”wires”:[[“ab19fe4b.1189c”]]},{“id”:”4dad2ac1.3cb674″,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”[144, 103, 120]”,”op2″:”[128, 103, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”300″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Ton blau”,”x”:760,”y”:580,”wires”:[[“ab19fe4b.1189c”]]},{“id”:”56e16f42.4b6a9″,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”[144, 95, 120]”,”op2″:”[128, 95, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”300″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Ton rot”,”x”:760,”y”:500,”wires”:[[“ab19fe4b.1189c”]]},{“id”:”b5c7d3c9.e0e81″,”type”:”trigger”,”z”:”2f0a4817.bfd318″,”op1″:”[144, 108, 120]”,”op2″:”[128, 108, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”300″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Ton schwarz”,”x”:770,”y”:620,”wires”:[[“ab19fe4b.1189c”]]},{“id”:”7c4eda7a.766e64″,”type”:”debug”,”z”:”2f0a4817.bfd318″,”name”:””,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”false”,”x”:980,”y”:460,”wires”:[]}]

 

Flow “Switchboard”

[{“id”:”815f762.61f0488″,”type”:”tab”,”label”:”Switchboard”,”disabled”:false,”info”:””},{“id”:”9a17e9df.9e96f8″,”type”:”twitter in”,”z”:”815f762.61f0488″,”twitter”:””,”tags”:”@Buttonspace_org,#catandmousegame”,”user”:”false”,”name”:”Tweets to @Buttonspace_org”,”topic”:”tweets”,”inputs”:0,”x”:160,”y”:360,”wires”:[[“7df3466.b4160b8″,”9c8996a4.ec6598″]],”outputLabels”:[“1”]},{“id”:”e3297e15.0378c”,”type”:”twitter out”,”z”:”815f762.61f0488″,”twitter”:””,”name”:”Tweet on @buttonspace_org”,”x”:1980,”y”:840,”wires”:[]},{“id”:”78837dfc.155d04″,”type”:”speakerpi-output”,”z”:”815f762.61f0488″,”choose”:”givenfile”,”filename”:”/home/pi/Desktop/elephant.wav”,”channels”:”1″,”bitdepth”:”8″,”samplerate”:”11025″,”name”:”Output 1 – ELEPHANT SOUND”,”x”:1970,”y”:260,”wires”:[]},{“id”:”72e96939.6c7fc8″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”3″,”extend”:true,”units”:”s”,”reset”:””,”name”:””,”x”:1580,”y”:260,”wires”:[[“78837dfc.155d04”]]},{“id”:”c08c2eb1.02b58″,”type”:”rpi-gpio in”,”z”:”815f762.61f0488″,”name”:”Many Buttons GPIO 26″,”pin”:”37″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:140,”y”:460,”wires”:[[“5997f61f.c4f8c8”]]},{“id”:”5997f61f.c4f8c8″,”type”:”function”,”z”:”815f762.61f0488″,”name”:”Switch button”,”func”:”\nif (msg.payload == 0) {\n \n msg.payload = 1;\n \n\n} else {\n\nmsg.payload = 0;\n\n}\n\nreturn msg;\n”,”outputs”:1,”noerr”:0,”x”:380,”y”:460,”wires”:[[“f337c0c7.f197b”]]},{“id”:”f337c0c7.f197b”,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”2″,”extend”:true,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:”Wait for 3 Seconds”,”x”:610,”y”:460,”wires”:[[“63ad4bac.638714″,”4c49c704.57e788”]]},{“id”:”fd2c66e4.eec5f8″,”type”:”change”,”z”:”815f762.61f0488″,”name”:”Twitter Message”,”rules”:[{“t”:”set”,”p”:”payload”,”pt”:”msg”,”to”:”This is only a Test”,”tot”:”str”}],”action”:””,”property”:””,”from”:””,”to”:””,”reg”:false,”x”:2530,”y”:680,”wires”:[[]]},{“id”:”89371233.04cdd”,”type”:”rpi-gpio out”,”z”:”815f762.61f0488″,”name”:”gpio 17 CAT”,”pin”:”11″,”set”:true,”level”:”0″,”freq”:””,”out”:”out”,”x”:1930,”y”:700,”wires”:[]},{“id”:”d2e57e1c.5ae13″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:”0″,”op1type”:”num”,”op2type”:”str”,”duration”:”500″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”Entprellung Katze”,”x”:1630,”y”:700,”wires”:[[“89371233.04cdd”]]},{“id”:”366c15bf.bcdcea”,”type”:”rpi-gpio in”,”z”:”815f762.61f0488″,”name”:”Big Red Button GPIO 19″,”pin”:”35″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:150,”y”:520,”wires”:[[“308fff02.4e5a6”]]},{“id”:”308fff02.4e5a6″,”type”:”function”,”z”:”815f762.61f0488″,”name”:”Switch button”,”func”:”\nif (msg.payload == 0) {\n \n msg.payload = 1;\n \n\n} else {\n\nmsg.payload = 0;\n\n}\n\nreturn msg;\n”,”outputs”:1,”noerr”:0,”x”:380,”y”:520,”wires”:[[“fd93b1f6.2ed14”]]},{“id”:”fd93b1f6.2ed14″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”3″,”extend”:true,”units”:”s”,”reset”:””,”name”:””,”x”:580,”y”:520,”wires”:[[“63ad4bac.638714″,”4c49c704.57e788”]]},{“id”:”f7b65b5a.f972b8″,”type”:”function”,”z”:”815f762.61f0488″,”name”:”Twitter text”,”func”:”\nvar number = Math.round(Math.random()*1000);\n\nmsg.payload = \”Thank you for pushing my buttons! \” + number +\”.\”;\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:1610,”y”:840,”wires”:[[“e3297e15.0378c”]]},{“id”:”43152df7.d808f4″,”type”:”twitter in”,”z”:”815f762.61f0488″,”twitter”:””,”tags”:”#love”,”user”:”false”,”name”:”Twitter LOVE”,”topic”:”tweets”,”inputs”:0,”x”:210,”y”:1320,”wires”:[[“1159d435.cbeb5c”]]},{“id”:”ba165a2a.404358″,”type”:”speakerpi-output”,”z”:”815f762.61f0488″,”choose”:”givenfile”,”filename”:”/home/pi/Desktop/ting.wav”,”channels”:”1″,”bitdepth”:”8″,”samplerate”:”11025″,”name”:”Output 1 – LOVE SOUND”,”x”:1590,”y”:1320,”wires”:[]},{“id”:”1159d435.cbeb5c”,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”0.1″,”extend”:true,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:””,”x”:490,”y”:1320,”wires”:[[“ba165a2a.404358″,”ab45f0f.8970d1″,”c28a0aa3.52d3f8”]]},{“id”:”63ad4bac.638714″,”type”:”function”,”z”:”815f762.61f0488″,”name”:”Roll the dice – again!”,”func”:”// Initialise message array for 10 outputs\nvar msg_array = [null,null,null,null,null,null,null,null,null,null];\n\n// Output_probability: Gewichtung der Auswahl jedes Outputs\n// Basis ist 1, 0 wird nie ausgewählt\nvar o_p = [1,1,1,1,1,1,0,0,0,0];\n\n// Random weight: Faktor, der mit dem Zufallsarray multipliziert wird\nvar r_w = 100;\n\n// Array mit einer Zufallszahl pro Output, mit random_weight multipliziert\nvar output_random = [Math.random()*r_w*o_p[0],Math.random()*r_w*o_p[1],Math.random()*r_w*o_p[2],Math.random()*r_w*o_p[3],Math.random()*r_w*o_p[4],Math.random()*r_w*o_p[5],Math.random()*r_w*o_p[6],Math.random()*r_w*o_p[7],Math.random()*r_w*o_p[8],Math.random()*r_w*o_p[9]];\n\n// Grösste Zufallszahl auswählen, Position im Array finden\nvar max = Math.max(…output_random);\nvar array_id = output_random.indexOf(max);\n\n// Wert für den gewählten Output mit der grössten Zufallszahl zurückgeben\nmsg_array[array_id] = { payload: array_id };\n\nreturn msg_array;”,”outputs”:10,”noerr”:0,”x”:980,”y”:560,”wires”:[[“72e96939.6c7fc8″,”aad61541.2c3768″,”262860d9.8b88c”],[“2c660d07.e2bf22″,”262860d9.8b88c”],[“a037ef9.0b0c61″,”a6dbf1b2.e136c”,”262860d9.8b88c”],[“d2e57e1c.5ae13″,”aa45fc5c.7b32e”,”262860d9.8b88c”],[“f7b65b5a.f972b8″,”d4407e5b.cdc2d”,”262860d9.8b88c”],[“567c2995.a47fe8″,”262860d9.8b88c”],[“262860d9.8b88c”],[“262860d9.8b88c”],[“262860d9.8b88c”],[“262860d9.8b88c”]]},{“id”:”e9362361.cd4e7″,”type”:”rpi-gpio in”,”z”:”815f762.61f0488″,”name”:”Doorbell GPIO 18″,”pin”:”12″,”intype”:”up”,”debounce”:”25″,”read”:false,”x”:130,”y”:580,”wires”:[[“89e6db3c.fb7a28”]]},{“id”:”89e6db3c.fb7a28″,”type”:”function”,”z”:”815f762.61f0488″,”name”:”Switch button”,”func”:”\nif (msg.payload == 0) {\n \n msg.payload = 1;\n \n\n} else {\n\nmsg.payload = 0;\n\n}\n\nreturn msg;\n”,”outputs”:1,”noerr”:0,”x”:380,”y”:580,”wires”:[[“d394a5e2.fdf268”]]},{“id”:”d394a5e2.fdf268″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”3″,”extend”:true,”units”:”s”,”reset”:””,”name”:””,”x”:580,”y”:580,”wires”:[[“63ad4bac.638714″,”4c49c704.57e788”]]},{“id”:”567c2995.a47fe8″,”type”:”speakerpi-output”,”z”:”815f762.61f0488″,”choose”:”givenfile”,”filename”:”/home/pi/Desktop/doorbell_left.wav”,”channels”:”1″,”bitdepth”:”8″,”samplerate”:”11025″,”name”:”Doorbell”,”x”:1920,”y”:960,”wires”:[]},{“id”:”faf0dd7d.4e667″,”type”:”midi out”,”z”:”815f762.61f0488″,”name”:””,”midiport”:”1″,”x”:2500,”y”:500,”wires”:[]},{“id”:”aad61541.2c3768″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 101, 120]”,”op2″:”[128, 101, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”2735″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”F7 2735ms”,”x”:1590,”y”:180,”wires”:[[“faf0dd7d.4e667″,”81e176d9.ed05f8”]]},{“id”:”2c660d07.e2bf22″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 62, 120]”,”op2″:”[128, 62, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”3000″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”D4 3000ms”,”x”:1590,”y”:340,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”a037ef9.0b0c61″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 51, 120]”,”op2″:”[128, 51, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”750″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”D#3 750ms”,”x”:1590,”y”:460,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”aa45fc5c.7b32e”,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 65, 120]”,”op2″:”[128, 65, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”500″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”F4 500ms”,”x”:1610,”y”:740,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”c1572c40.9c858″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 35, 120]”,”op2″:”[128, 35, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”3000″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”B1 3000ms”,”x”:2050,”y”:1040,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”fbec9e47.ac2ea”,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 77, 120]”,”op2″:”[128, 77, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”1546″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”F5 1546ms”,”x”:2050,”y”:1120,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”ffaaea90.b92d18″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 71, 120]”,”op2″:”[128, 71, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”500″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”B4 500ms”,”x”:2050,”y”:1200,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”d4407e5b.cdc2d”,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 72, 120]”,”op2″:”[128, 72, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”500″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”C5 500ms”,”x”:1610,”y”:880,”wires”:[[“faf0dd7d.4e667”]]},{“id”:”cc9873ec.ad621″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”F7″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1250,”y”:180,”wires”:[[“aad61541.2c3768”]]},{“id”:”f6b8fbf8.a54608″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”D4″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1250,”y”:340,”wires”:[[“2c660d07.e2bf22”]]},{“id”:”4249dff0.91951″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”D#3″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1250,”y”:460,”wires”:[[“a037ef9.0b0c61”]]},{“id”:”56de7fe9.48473″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”F4″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1230,”y”:740,”wires”:[[“aa45fc5c.7b32e”]]},{“id”:”eccdbbb2.25f618″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”B1″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1230,”y”:1040,”wires”:[[“c1572c40.9c858”]]},{“id”:”52a26856.9f5f98″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”F5″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1230,”y”:1100,”wires”:[[“fbec9e47.ac2ea”]]},{“id”:”847ce843.2b9258″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”C5″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1230,”y”:880,”wires”:[[“d4407e5b.cdc2d”]]},{“id”:”97715d32.4ca9″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”B4″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1230,”y”:1180,”wires”:[[“ffaaea90.b92d18”]]},{“id”:”81e176d9.ed05f8″,”type”:”debug”,”z”:”815f762.61f0488″,”name”:””,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”false”,”x”:1910,”y”:180,”wires”:[]},{“id”:”2dda151e.93fc5a”,”type”:”midi in”,”z”:”815f762.61f0488″,”name”:”Midi Keyboard input”,”midiport”:”1″,”x”:130,”y”:640,”wires”:[[“2913990f.771a06”]]},{“id”:”2913990f.771a06″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”3″,”extend”:true,”units”:”s”,”reset”:””,”name”:””,”x”:580,”y”:640,”wires”:[[“63ad4bac.638714″,”4c49c704.57e788”]]},{“id”:”fcd8d37b.baa6c”,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Inputs”,”info”:””,”x”:110,”y”:60,”wires”:[]},{“id”:”149ba268.50bfbe”,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Process Inputs (1/2)”,”info”:””,”x”:410,”y”:60,”wires”:[]},{“id”:”35ca7eae.ba27a2″,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Process Inputs (2/2)”,”info”:””,”x”:630,”y”:60,”wires”:[]},{“id”:”9af1c693.ce0398″,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Switchboard”,”info”:””,”x”:970,”y”:60,”wires”:[]},{“id”:”a8e46842.79c728″,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Direct inputs”,”info”:””,”x”:1250,”y”:60,”wires”:[]},{“id”:”b2f0cab.4b41e38″,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Process outputs”,”info”:””,”x”:1620,”y”:60,”wires”:[]},{“id”:”5410fd8b.2997a4″,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Events”,”info”:””,”x”:1910,”y”:60,”wires”:[]},{“id”:”b136ac9f.ea3d4″,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Midi out”,”info”:””,”x”:2510,”y”:60,”wires”:[]},{“id”:”a6dbf1b2.e136c”,”type”:”debug”,”z”:”815f762.61f0488″,”name”:”Licht”,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”payload”,”x”:1790,”y”:640,”wires”:[]},{“id”:”7df3466.b4160b8″,”type”:”switch”,”z”:”815f762.61f0488″,”name”:”if msg contains catandmousegame”,”property”:”payload”,”propertyType”:”msg”,”rules”:[{“t”:”cont”,”v”:”catandmousegame”,”vt”:”str”},{“t”:”else”}],”checkall”:”true”,”repair”:false,”outputs”:2,”x”:500,”y”:400,”wires”:[[“4c49c704.57e788″,”d2e57e1c.5ae13”],[“63ad4bac.638714″,”4c49c704.57e788”]]},{“id”:”9c8996a4.ec6598″,”type”:”debug”,”z”:”815f762.61f0488″,”name”:””,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”false”,”x”:480,”y”:320,”wires”:[]},{“id”:”c28a0aa3.52d3f8″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”[144, 89, 120]”,”op2″:”[128, 89, 120]”,”op1type”:”json”,”op2type”:”json”,”duration”:”1500″,”extend”:false,”units”:”ms”,”reset”:””,”bytopic”:”all”,”name”:”F6 1500ms”,”x”:2050,”y”:1280,”wires”:[[]]},{“id”:”b7dcb7fd.291158″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”F6″,”topic”:””,”payload”:””,”payloadType”:”str”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1230,”y”:1260,”wires”:[[“c28a0aa3.52d3f8”]]},{“id”:”ab45f0f.8970d1″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”7″,”extend”:false,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:””,”x”:500,”y”:1220,”wires”:[[“a5059e8b.c3db7″,”2827ad7.9e28052”]]},{“id”:”7efa694f.876d58″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”17″,”extend”:false,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:””,”x”:910,”y”:1160,”wires”:[[“ffaaea90.b92d18″,”a084b6b0.801098”]]},{“id”:”2827ad7.9e28052″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”13″,”extend”:false,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:””,”x”:750,”y”:1160,”wires”:[[“7efa694f.876d58”]]},{“id”:”a5059e8b.c3db7″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”45″,”extend”:false,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:””,”x”:750,”y”:1100,”wires”:[[“c1572c40.9c858”]]},{“id”:”2d50f321.cb895c”,”type”:”comment”,”z”:”815f762.61f0488″,”name”:”Love Sub-Flow”,”info”:””,”x”:220,”y”:1400,”wires”:[]},{“id”:”a084b6b0.801098″,”type”:”trigger”,”z”:”815f762.61f0488″,”op1″:”1″,”op2″:””,”op1type”:”str”,”op2type”:”nul”,”duration”:”43″,”extend”:false,”units”:”s”,”reset”:””,”bytopic”:”all”,”name”:””,”x”:1070,”y”:1120,”wires”:[[“fbec9e47.ac2ea”]]},{“id”:”f764f57a.b336f8″,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”On”,”topic”:””,”payload”:”true”,”payloadType”:”bool”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1770,”y”:540,”wires”:[[“490a9887.aeaa28″,”b10b93d3.f9371”]]},{“id”:”5ffb60e5.63afa”,”type”:”inject”,”z”:”815f762.61f0488″,”name”:”Off”,”topic”:””,”payload”:”false”,”payloadType”:”bool”,”repeat”:””,”crontab”:””,”once”:false,”onceDelay”:0.1,”x”:1770,”y”:580,”wires”:[[“490a9887.aeaa28″,”b10b93d3.f9371”]]},{“id”:”490a9887.aeaa28″,”type”:”debug”,”z”:”815f762.61f0488″,”name”:””,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”false”,”x”:2140,”y”:520,”wires”:[]},{“id”:”4c49c704.57e788″,”type”:”debug”,”z”:”815f762.61f0488″,”name”:”Input”,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”payload”,”x”:870,”y”:720,”wires”:[]},{“id”:”262860d9.8b88c”,”type”:”debug”,”z”:”815f762.61f0488″,”name”:”Output”,”active”:true,”tosidebar”:true,”console”:false,”tostatus”:false,”complete”:”payload”,”x”:1030,”y”:720,”wires”:[]},{“id”:”b10b93d3.f9371″,”type”:”smartplug-out”,”z”:”815f762.61f0488″,”name”:”plug1″,”topic”:””,”device”:”1b6b0b93.fa9f54″,”response”:true,”x”:1940,”y”:600,”wires”:[[“490a9887.aeaa28”]]},{“id”:”1b6b0b93.fa9f54″,”type”:”smartplug-device”,”z”:””,”name”:”Plug22c3d3″,”host”:”10.0.0.100″,”timeout”:”100″,”heartbeat”:”5″}]