Qlab control

Node-Red_QLab

Node-Red control of Qlab and Qlab returning to Node-Red

The aim of this project was a remote location where there will be a local micriphone, this is connected via Dante back to our main audio DSP, the DSP is BSS SoundWeb and may be controlled directly but also may be controled from Qlab. As i don't have a soundweb unit on my desk Qlab is a good way of proving it's all working.

Components -There are two switches connected to the GPIs of the Rasperry Pi along with a DHT22.
-On the Raspberry Pi is Node-Red -On my Mac i'm running Qlab.

The GPIs enter the flow and depending on if they are depressed for a long or a short time they behave in a momentary or latching behaviour.

These inputs are passed to figure53 Qlab where they open up the microphone to the appropiate zone. Within Qlab cues there are commands that return to the Node-Red flow. These returns from Qlab trigger the GPOs which are connected to the two LEDs to confirm to the operator that the microphone is live.

The Node-Red flow is also contains a Dashboard which shows the state of the switches allows for a visual conformaiton they are working and to operate the swithces from the UI.

The Node-Red dashboard also displays the metrics of the pi and the DHT22 sensor, as ultimatley this will be positiooned outdoors in a weather proof enclosure.

The Qlab files are included, along with a videos showing it in action.

The Project

2020-04-03_08 11 58sm

The Main Flow - The LED's are just at the end of the triggers for some other testing!

The Stats Flow

The Dashboard

I need to fix the issue of the free memory being over 100% Screenshot 2020-04-03 at 13 52 19

The Wiring Diagram

wiring_diagram

Wiring Schematic

wiring_schematic

The Project in Action

https://youtu.be/xk8CGJNfmUY

[{"id":"881975da.a3c468","type":"tab","label":"Queue Lane - Qlab V1","disabled":true,"info":""},{"id":"d1a5dd87.52da8","type":"tab","label":"Queue Lane - Qlab V2","disabled":false,"info":""},{"id":"b5a5d9b2.c1315","type":"tab","label":"Queue Lane Rpi Status","disabled":false,"info":""},{"id":"76f61516.0cd434","type":"tab","label":"Flow 1","disabled":true,"info":""},{"id":"e484b559.67019","type":"ui_base","z":"","theme":{"name":"theme-custom","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Wimbledon","default":"#4B7930","baseColor":"#00653a","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","reset":false},"themeState":{"base-color":{"default":"#00653a","value":"#00653a","edited":true},"page-titlebar-backgroundColor":{"value":"#004131","edited":true},"page-backgroundColor":{"value":"#390063","edited":true},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#00b166","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#004131","edited":true},"widget-textColor":{"value":"#adb1b8","edited":true},"widget-backgroundColor":{"value":"#fffc40","edited":true},"widget-borderColor":{"value":"#004131","edited":true},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Queue Lane Microphone","hideToolbar":"false","allowSwipe":"false","lockMenu":"true","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"b7d4b5f3.10fc58","type":"ui_group","z":"","name":"Temperatures","tab":"fbc9eb65.e88ff","order":2,"disp":true,"width":"4","collapse":false},{"id":"fbc9eb65.e88ff","type":"ui_tab","z":"","name":"Queue Lane","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"edbefee9.e1a238","type":"ui_group","z":"","name":"Switch State","tab":"fbc9eb65.e88ff","order":1,"disp":true,"width":4,"collapse":false},{"id":"ea7482ad.3a49e","type":"ui_group","z":"","name":"hidden_group","tab":"8fad4ccd.d4317","order":1,"disp":false,"width":"6","collapse":false},{"id":"8fad4ccd.d4317","type":"ui_tab","z":"","name":"zClock Display","icon":"home","order":2,"disabled":true,"hidden":false},{"id":"30a2d5fe.6977f2","type":"qlab config","z":"","ipAddress":"10.1.1.54","protocol":"udp","name":"Brew Touchbar"},{"id":"2d9a7007.88a3b","type":"ui_group","name":"Group 1","tab":"","order":1,"disp":true,"width":6},{"id":"55ed6438.12cbfc","type":"ui_spacer","name":"spacer","group":"2d9a7007.88a3b","order":1,"width":1,"height":1},{"id":"422393b3.1230cc","type":"rpi-gpio in","z":"881975da.a3c468","name":"11-Sw1","pin":"11","intype":"up","debounce":"25","read":false,"x":70,"y":80,"wires":[["a0afdb61.733b3"]]},{"id":"61c2ab0.eff64d4","type":"rpi-gpio in","z":"881975da.a3c468","name":"12-Sw2","pin":"12","intype":"up","debounce":"25","read":false,"x":70,"y":180,"wires":[["92cd845a.1a49b"]]},{"id":"16c2553d.aac89b","type":"rpi-gpio out","z":"881975da.a3c468","name":"15-Sw1 LED","pin":"15","set":true,"level":"0","freq":"","out":"out","x":1430,"y":360,"wires":[]},{"id":"6a91450d.08085c","type":"rpi-gpio out","z":"881975da.a3c468","name":"16-Sw2 LED","pin":"16","set":true,"level":"0","freq":"","out":"out","x":1430,"y":480,"wires":[]},{"id":"28425e06.f2483a","type":"inject","z":"881975da.a3c468","name":"On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":340,"wires":[["432530be.b3a9c8","80157a87.0a0ea"]]},{"id":"a03bf585.67a2b8","type":"inject","z":"881975da.a3c468","name":"Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":420,"wires":[["432530be.b3a9c8","80157a87.0a0ea"]]},{"id":"432530be.b3a9c8","type":"ui_switch","z":"881975da.a3c468","name":"","label":"Sw1 op","tooltip":"","group":"edbefee9.e1a238","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":740,"y":380,"wires":[["80157a87.0a0ea"]]},{"id":"b7bfebe3.20a38","type":"ui_switch","z":"881975da.a3c468","name":"","label":"Sw1 ip","tooltip":"","group":"edbefee9.e1a238","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":490,"y":80,"wires":[["d610817a.ee509"]]},{"id":"556fcc28.9a5c0c","type":"inject","z":"881975da.a3c468","name":"On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":460,"wires":[["65422744.a00dc","747ac158.b0de8"]]},{"id":"7cebdc24.003a54","type":"inject","z":"881975da.a3c468","name":"Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":540,"wires":[["65422744.a00dc","747ac158.b0de8"]]},{"id":"65422744.a00dc","type":"ui_switch","z":"881975da.a3c468","name":"","label":"Sw2 op","tooltip":"","group":"edbefee9.e1a238","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":740,"y":500,"wires":[["747ac158.b0de8"]]},{"id":"a0afdb61.733b3","type":"switch","z":"881975da.a3c468","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":80,"wires":[["17d6ef7b.6a5181"],["e77e3f4.32d5c4"]]},{"id":"17d6ef7b.6a5181","type":"change","z":"881975da.a3c468","name":"Change to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":60,"wires":[["b7bfebe3.20a38"]]},{"id":"e77e3f4.32d5c4","type":"change","z":"881975da.a3c468","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":100,"wires":[["b7bfebe3.20a38"]]},{"id":"17a33532.bea433","type":"ui_switch","z":"881975da.a3c468","name":"","label":"Sw2 ip","tooltip":"","group":"edbefee9.e1a238","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":490,"y":180,"wires":[["4b5de648.d20d"]]},{"id":"92cd845a.1a49b","type":"switch","z":"881975da.a3c468","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":180,"wires":[["c1dcc0aa.011358"],["bc37472f.c634f8"]]},{"id":"c1dcc0aa.011358","type":"change","z":"881975da.a3c468","name":"Change to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":160,"wires":[["17a33532.bea433"]]},{"id":"bc37472f.c634f8","type":"change","z":"881975da.a3c468","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":200,"wires":[["17a33532.bea433"]]},{"id":"a82f108c.e6bf08","type":"qlab in","z":"881975da.a3c468","port":"53003","passcode":"","name":"QLab Lsn","x":80,"y":440,"wires":[["f02689e3.68822"]]},{"id":"d610817a.ee509","type":"switch","z":"881975da.a3c468","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":80,"wires":[["c87406ab.6bdde8"],["65fd9dd5.ae14b4"]]},{"id":"c87406ab.6bdde8","type":"qlab out","z":"881975da.a3c468","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z1_on}/start","name":"z1_on","x":750,"y":60,"wires":[]},{"id":"61cbfad8.751374","type":"qlab out","z":"881975da.a3c468","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z2_on}/start","name":"z2_on","x":750,"y":160,"wires":[]},{"id":"af99f0a9.a07028","type":"qlab out","z":"881975da.a3c468","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z2_off}/start","name":"z2_off","x":750,"y":200,"wires":[]},{"id":"4b5de648.d20d","type":"switch","z":"881975da.a3c468","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":180,"wires":[["61cbfad8.751374"],["af99f0a9.a07028"]]},{"id":"f02689e3.68822","type":"switch","z":"881975da.a3c468","name":"Zone Filter","property":"payload.address","propertyType":"msg","rules":[{"t":"eq","v":"/zone1","vt":"str"},{"t":"eq","v":"/zone2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":440,"wires":[["8062e833.356f1"],["2a085d83.e2075a"]]},{"id":"5eaf84bd.2a8794","type":"exec","z":"b5a5d9b2.c1315","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"false","timer":"","name":"CPU Temp","x":350,"y":320,"wires":[["2840e21.347911e","ecc4ef2.df7441"],[],[]]},{"id":"5c40bb10.84fdac","type":"inject","z":"b5a5d9b2.c1315","name":"","topic":"","payload":"","payloadType":"date","repeat":"20","crontab":"","once":true,"onceDelay":"","x":133,"y":382,"wires":[["b6e2bc6d.eba04","5eaf84bd.2a8794","780d89ae.01453"]]},{"id":"2840e21.347911e","type":"function","z":"b5a5d9b2.c1315","name":"Number Only","func":"str = msg.payload \nmsg.payload  = str.substring(5, 9);\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":320,"wires":[["c8b82993.fc07c8","137c019f.3fe486"]]},{"id":"c8b82993.fc07c8","type":"ui_gauge","z":"b5a5d9b2.c1315","name":"CPU Temperature","group":"b7d4b5f3.10fc58","order":2,"width":4,"height":3,"gtype":"gage","title":"CPU Temp.","label":"°C","format":"{{value}}","min":0,"max":"90","colors":["#00b500","#b6e203","#ca3838"],"seg1":"","seg2":"","x":760,"y":300,"wires":[]},{"id":"b6e2bc6d.eba04","type":"exec","z":"b5a5d9b2.c1315","command":"top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'","addpay":false,"append":"","useSpawn":"false","timer":"","name":"CPU Load","x":350,"y":380,"wires":[["3c72f596.bbb2fa","ce67b0c.658f9d"],[],[]]},{"id":"3c72f596.bbb2fa","type":"ui_gauge","z":"b5a5d9b2.c1315","name":"CPU Load","group":"b7d4b5f3.10fc58","order":4,"width":4,"height":3,"gtype":"gage","title":"CPU Load","label":"%","format":"{{value}}","min":0,"max":"90","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":580,"y":360,"wires":[]},{"id":"780d89ae.01453","type":"exec","z":"b5a5d9b2.c1315","command":"free | grep Mem | awk '{print 100*($4+$6+$7)/$2}'","addpay":false,"append":"","useSpawn":"false","timer":"","name":"Free Memory","x":360,"y":440,"wires":[["ba079451.4c826"],[],[]]},{"id":"ba079451.4c826","type":"ui_text","z":"b5a5d9b2.c1315","group":"b7d4b5f3.10fc58","order":3,"width":4,"height":1,"name":"Free Memory","label":"Free Mem:","format":"{{msg.payload}}%","layout":"row-center","x":570,"y":440,"wires":[]},{"id":"5b905816.79fb98","type":"inject","z":"b5a5d9b2.c1315","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":180,"wires":[["2100e631.5b23ca"]]},{"id":"a267abe.07d66d8","type":"ui_gauge","z":"b5a5d9b2.c1315","name":"Box Temperature","group":"b7d4b5f3.10fc58","order":1,"width":4,"height":3,"gtype":"gage","title":"Box Temp","label":"°C","format":"{{value}}","min":"0","max":"40","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":510,"y":140,"wires":[]},{"id":"ce8bad2a.fbc06","type":"ui_template","z":"b5a5d9b2.c1315","group":"ea7482ad.3a49e","name":"Clock Toolbar","order":2,"width":"0","height":"0","format":"<script id=\"titleScript\" type=\"text/javascript\">\n\n$(function() {\n    if($('.md-toolbar-tools').length != 0){\n        loadClock();\n    }else setTimeout(loadClock, 500)\n});\n\nfunction loadClock(){\n    $('#clock').remove();\n    var toolbar = $('.md-toolbar-tools');\n    \n    var div = $('<div/>');\n    var p = $('<p/ id=\"clock\">');\n    \n    div.append(p);\n    div[0].style.margin = '5px 5px 5px auto';\n    toolbar.append(div);\n\n    function displayTitle(lh) {\n        p.text(lh); \n    }\n    \n    function upTime() {\n        var d = new Date();\n        p.text(d.toLocaleString());\n    }\n\n    if(document.clockInterval){ \n            clearInterval(document.clockInterval);\n            document.clockInterval = null;\n    }\n        \n    document.clockInterval = setInterval(upTime,1000);\n}\n\n</script>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"global","x":120,"y":80,"wires":[[]]},{"id":"79f4a91c.7cdcf8","type":"comment","z":"881975da.a3c468","name":"Qlab Message","info":"03/04/2020, 11:01:10node: 50361748.925e68\nmsg : Object\nobject\npayload: object\naddress: \"/zone1\"\nargs: array[1]\npacketInfo: object\naddress: \"10.1.1.54\"\nfamily: \"IPv4\"\nport: 51152\nsize: 16\n_msgid: \"fe3edea9.47053\"","x":100,"y":480,"wires":[]},{"id":"8062e833.356f1","type":"switch","z":"881975da.a3c468","name":"split","property":"payload.args","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":380,"wires":[["6fba814f.9d317"],["dd3fe031.72f938"]]},{"id":"6fba814f.9d317","type":"change","z":"881975da.a3c468","name":"Change to 1 On","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":360,"wires":[["432530be.b3a9c8"]]},{"id":"dd3fe031.72f938","type":"change","z":"881975da.a3c468","name":"Change to 0 Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":400,"wires":[["432530be.b3a9c8"]]},{"id":"2a085d83.e2075a","type":"switch","z":"881975da.a3c468","name":"split","property":"payload.args","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":500,"wires":[["788f000e.7ee518"],["90d4db98.c12538"]]},{"id":"788f000e.7ee518","type":"change","z":"881975da.a3c468","name":"Change to 1 On","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":480,"wires":[["65422744.a00dc"]]},{"id":"90d4db98.c12538","type":"change","z":"881975da.a3c468","name":"Change to 0 Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":520,"wires":[["65422744.a00dc"]]},{"id":"65fd9dd5.ae14b4","type":"qlab out","z":"881975da.a3c468","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z1_off}/start","name":"z1_off","x":750,"y":100,"wires":[]},{"id":"d2583356.d36458","type":"comment","z":"881975da.a3c468","name":"Switch Inputs","info":"Switch Inputs from Rpi GPI pin 11 and 12","x":90,"y":20,"wires":[]},{"id":"1275747d.a0ca9c","type":"comment","z":"881975da.a3c468","name":"Message Handling","info":"","x":290,"y":20,"wires":[]},{"id":"84d5000.f55ee","type":"comment","z":"881975da.a3c468","name":"Indicator Switch","info":"","x":500,"y":20,"wires":[]},{"id":"e623a66f.fbbe28","type":"comment","z":"881975da.a3c468","name":"OSC Message to Qlab","info":"","x":800,"y":20,"wires":[]},{"id":"30081e08.e58242","type":"comment","z":"881975da.a3c468","name":"OSC received from Qlab","info":"","x":130,"y":300,"wires":[]},{"id":"2fe9f305.87b9b4","type":"comment","z":"881975da.a3c468","name":"Filter and message handling","info":"","x":440,"y":300,"wires":[]},{"id":"d08c836.194c6","type":"comment","z":"881975da.a3c468","name":"Indicator and manual switch","info":"","x":760,"y":300,"wires":[]},{"id":"52f28ff6.7295","type":"comment","z":"881975da.a3c468","name":"GPO LEDs","info":"LED outputs GPIO 15 and 16","x":1430,"y":300,"wires":[]},{"id":"78f0151f.c13d0c","type":"comment","z":"b5a5d9b2.c1315","name":"Clock Display top of Dashboard","info":"","x":170,"y":40,"wires":[]},{"id":"f09f396e.bcf5f","type":"comment","z":"b5a5d9b2.c1315","name":"Interrogate temperature in enclosure","info":"","x":180,"y":140,"wires":[]},{"id":"be1b88ad.0fe4","type":"comment","z":"b5a5d9b2.c1315","name":"Interrogate Rpi load status","info":"","x":150,"y":280,"wires":[]},{"id":"ff70e0e8.76d36","type":"trigger","z":"881975da.a3c468","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":1220,"y":360,"wires":[["b4d4ce0.4454f3","16c2553d.aac89b"]]},{"id":"b4d4ce0.4454f3","type":"function","z":"881975da.a3c468","name":"","func":"if (msg.payload == \"off\")\n\tcontext.state = 0;\nif (msg.payload == \"on\")\n\tcontext.state = 1;\n\nif (context.state == 1)\n{\n\tif (msg.payload == 0)\n\t\treturn msg;\n\telse\n\t\treturn;\n}\nelse\n\treturn;","outputs":1,"noerr":0,"x":1070,"y":420,"wires":[["5b50bd02.42c0b4"]]},{"id":"80157a87.0a0ea","type":"switch","z":"881975da.a3c468","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":380,"wires":[["b4d4ce0.4454f3","ff70e0e8.76d36"],["b4d4ce0.4454f3"]]},{"id":"5b50bd02.42c0b4","type":"delay","z":"881975da.a3c468","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":420,"wires":[["ff70e0e8.76d36"]]},{"id":"dd5a68ce.531cc","type":"trigger","z":"881975da.a3c468","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":1220,"y":480,"wires":[["f99cbca7.51b42","6a91450d.08085c"]]},{"id":"f99cbca7.51b42","type":"function","z":"881975da.a3c468","name":"","func":"if (msg.payload == \"off\")\n\tcontext.state = 0;\nif (msg.payload == \"on\")\n\tcontext.state = 1;\n\nif (context.state == 1)\n{\n\tif (msg.payload == 0)\n\t\treturn msg;\n\telse\n\t\treturn;\n}\nelse\n\treturn;","outputs":1,"noerr":0,"x":1070,"y":540,"wires":[["afe94b3c.c18aa"]]},{"id":"747ac158.b0de8","type":"switch","z":"881975da.a3c468","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":500,"wires":[["f99cbca7.51b42","dd5a68ce.531cc"],["f99cbca7.51b42"]]},{"id":"afe94b3c.c18aa","type":"delay","z":"881975da.a3c468","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":540,"wires":[["dd5a68ce.531cc"]]},{"id":"401354fa.29640c","type":"comment","z":"881975da.a3c468","name":"Blinking LED","info":"","x":1090,"y":300,"wires":[]},{"id":"137c019f.3fe486","type":"ui_chart","z":"b5a5d9b2.c1315","name":"","group":"b7d4b5f3.10fc58","order":4,"width":0,"height":0,"label":"CPU Temp","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":740,"y":340,"wires":[[]]},{"id":"ce67b0c.658f9d","type":"ui_chart","z":"b5a5d9b2.c1315","name":"","group":"b7d4b5f3.10fc58","order":5,"width":0,"height":0,"label":"CPU Load","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":580,"y":400,"wires":[[]]},{"id":"e7f8a7aa.9a25c","type":"ui_chart","z":"b5a5d9b2.c1315","name":"","group":"b7d4b5f3.10fc58","order":6,"width":0,"height":0,"label":"Box","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":470,"y":220,"wires":[[]]},{"id":"2100e631.5b23ca","type":"rpi-dht22","z":"b5a5d9b2.c1315","name":"","topic":"rpi-dht22","dht":22,"pintype":"0","pin":4,"x":280,"y":180,"wires":[["a267abe.07d66d8","e7f8a7aa.9a25c","4777deed.b22528"]]},{"id":"4777deed.b22528","type":"file","z":"b5a5d9b2.c1315","name":"Box_Temp.log","filename":"logs/Box_Temp.log","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":480,"y":180,"wires":[[]]},{"id":"ecc4ef2.df7441","type":"file","z":"b5a5d9b2.c1315","name":"CPU_Temp.log","filename":"logs/CPU_Temp.log","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":540,"y":280,"wires":[[]]},{"id":"538b67f5.1de118","type":"rpi-gpio out","z":"76f61516.0cd434","name":"15-Sw1 LED","pin":"15","set":true,"level":"0","freq":"","out":"out","x":1110,"y":80,"wires":[]},{"id":"d955cd9e.485df","type":"inject","z":"76f61516.0cd434","name":"On","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":950,"y":40,"wires":[["538b67f5.1de118"]]},{"id":"da20102.9565af","type":"inject","z":"76f61516.0cd434","name":"Off","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":950,"y":120,"wires":[["538b67f5.1de118"]]},{"id":"5efa92e9.31d47c","type":"rpi-gpio in","z":"76f61516.0cd434","name":"11-Sw1","pin":"11","intype":"up","debounce":"25","read":false,"x":50,"y":80,"wires":[["da93a853.308cc8","2e4f9089.367a5"]]},{"id":"f339bee9.416688","type":"ui_switch","z":"76f61516.0cd434","name":"","label":"Sw1 ip","tooltip":"","group":"edbefee9.e1a238","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":950,"y":80,"wires":[["538b67f5.1de118"]]},{"id":"d6ca79ea.a585a","type":"switch","z":"76f61516.0cd434","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":80,"wires":[["23cf4242.dfe446"],["e418d81.ddd9628"]]},{"id":"23cf4242.dfe446","type":"change","z":"76f61516.0cd434","name":"Change to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":60,"wires":[["f339bee9.416688"]]},{"id":"e418d81.ddd9628","type":"change","z":"76f61516.0cd434","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":100,"wires":[["f339bee9.416688"]]},{"id":"2e4f9089.367a5","type":"function","z":"76f61516.0cd434","name":"Rising Only (Toggle)","func":"var i=context.get('i') || 0;\nvar payload=msg.payload;\ncontext.set(\"i\",Math.abs(i-payload));\nmsg.payload=i;\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":80,"wires":[["d6ca79ea.a585a"]],"info":"https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=284357&sid=e3973749fd4c6596fbba38ffc79847c2\nchrisgal\n\nRe: Node Red toggle function\nQuote\nSun Dec 16, 2018 4:55 am\n\nA very simple function to use with a push button.\nState of button is send as input of function (msg.payload), 1 if pushing 0 if releasing.\nOutput of the function toggles between 0 and 1 when pushing the button, no change when releasing.\n\nvar i=context.get('i') || 0;\nvar payload=msg.payload;\ncontext.set(\"i\",Math.abs(i-payload));\nvar payload=msg.payload;\nmsg.payload=i;\nreturn msg;"},{"id":"276f0be5.f4bfc4","type":"change","z":"76f61516.0cd434","name":"add timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    'state': payload,\t    'timestamp': $millis()\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":160,"wires":[["cf496df8.2f85"]]},{"id":"cf496df8.2f85","type":"join","z":"76f61516.0cd434","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload.state","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":610,"y":160,"wires":[["8f427b28.2ea7d8"]]},{"id":"8f427b28.2ea7d8","type":"change","z":"76f61516.0cd434","name":"Threshold","rules":[{"t":"set","p":"threshold","pt":"msg","to":"500","tot":"num"},{"t":"set","p":"delta","pt":"msg","to":"$lookup(payload, '0').timestamp - $lookup(payload, '1').timestamp","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"delta < threshold ? 'short' : 'long'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":160,"wires":[["a0079184.c39ff8"]]},{"id":"da93a853.308cc8","type":"switch","z":"76f61516.0cd434","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":160,"wires":[["968baad6.be1458"],["e28a0e58.95d65"]]},{"id":"968baad6.be1458","type":"change","z":"76f61516.0cd434","name":"Change to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":140,"wires":[["276f0be5.f4bfc4"]]},{"id":"e28a0e58.95d65","type":"change","z":"76f61516.0cd434","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":180,"wires":[["276f0be5.f4bfc4"]]},{"id":"a0079184.c39ff8","type":"switch","z":"76f61516.0cd434","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"long","vt":"str"},{"t":"eq","v":"short","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":160,"wires":[["934fda84.bd16f8"],[]]},{"id":"934fda84.bd16f8","type":"change","z":"76f61516.0cd434","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":160,"wires":[["a27fb31e.06bda"]]},{"id":"2da9cd68.21957a","type":"rpi-gpio in","z":"d1a5dd87.52da8","name":"11-Sw1","pin":"11","intype":"up","debounce":"25","read":false,"x":70,"y":100,"wires":[["2ed1b06e.d1db3","2781db70.2dadfc"]]},{"id":"97eb36b5.ec2988","type":"rpi-gpio in","z":"d1a5dd87.52da8","name":"12-Sw2","pin":"12","intype":"up","debounce":"25","read":false,"x":70,"y":220,"wires":[["49bd81bb.6e71f","c36d7470.053a2"]]},{"id":"bf4019e5.152aa","type":"rpi-gpio out","z":"d1a5dd87.52da8","name":"15-Sw1 LED","pin":"15","set":true,"level":"0","freq":"","out":"out","x":1430,"y":540,"wires":[]},{"id":"84cfa4eb.645fd8","type":"rpi-gpio out","z":"d1a5dd87.52da8","name":"16-Sw2 LED","pin":"16","set":true,"level":"0","freq":"","out":"out","x":1430,"y":660,"wires":[]},{"id":"eda58c18.5b3ad","type":"inject","z":"d1a5dd87.52da8","name":"On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":520,"wires":[["198fa66b.22a0b2","82e17e03.3daa08"]]},{"id":"5ca19653.8312f8","type":"inject","z":"d1a5dd87.52da8","name":"Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":600,"wires":[["198fa66b.22a0b2","82e17e03.3daa08"]]},{"id":"198fa66b.22a0b2","type":"ui_switch","z":"d1a5dd87.52da8","name":"","label":"Sw1 op","tooltip":"","group":"edbefee9.e1a238","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":740,"y":560,"wires":[["82e17e03.3daa08"]]},{"id":"13158fc7.7b869","type":"ui_switch","z":"d1a5dd87.52da8","name":"","label":"Sw1 ip","tooltip":"","group":"edbefee9.e1a238","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":1330,"y":100,"wires":[["af1a97df.ae2168","12a2521.57ba52e"]]},{"id":"237f0ba0.80a3fc","type":"inject","z":"d1a5dd87.52da8","name":"On","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":640,"wires":[["e6fff1b4.416558","b77e0534.26689"]]},{"id":"f2317d88.e42378","type":"inject","z":"d1a5dd87.52da8","name":"Off","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":710,"y":720,"wires":[["e6fff1b4.416558","b77e0534.26689"]]},{"id":"e6fff1b4.416558","type":"ui_switch","z":"d1a5dd87.52da8","name":"","label":"Sw2 op","tooltip":"","group":"edbefee9.e1a238","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":740,"y":680,"wires":[["b77e0534.26689"]]},{"id":"17bbed50.a94c5b","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1030,"y":100,"wires":[["5850adc8.979f94"],["99382718.ced71"]]},{"id":"5850adc8.979f94","type":"change","z":"d1a5dd87.52da8","name":"Change to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":80,"wires":[["13158fc7.7b869"]]},{"id":"99382718.ced71","type":"change","z":"d1a5dd87.52da8","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":120,"wires":[["13158fc7.7b869"]]},{"id":"8baee8ab.15759","type":"ui_switch","z":"d1a5dd87.52da8","name":"","label":"Sw2 ip","tooltip":"","group":"edbefee9.e1a238","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":1330,"y":220,"wires":[["68951166.17912","d9aff087.39e93"]]},{"id":"3616661e.8f57c2","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1030,"y":220,"wires":[["e30f8a0c.7709f"],["dd274a37.506598"]]},{"id":"e30f8a0c.7709f","type":"change","z":"d1a5dd87.52da8","name":"Change to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":200,"wires":[["8baee8ab.15759"]]},{"id":"dd274a37.506598","type":"change","z":"d1a5dd87.52da8","name":"Change to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":240,"wires":[["8baee8ab.15759"]]},{"id":"f837de75.b5eef8","type":"qlab in","z":"d1a5dd87.52da8","port":"53003","passcode":"","name":"QLab Lsn","x":80,"y":620,"wires":[["c3b0febf.acc2e"]]},{"id":"af1a97df.ae2168","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1450,"y":100,"wires":[["ff6f692a.6c966"],["8c51e78f.a70ba8"]]},{"id":"ff6f692a.6c966","type":"qlab out","z":"d1a5dd87.52da8","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z1_on}/start","name":"z1_on","x":1590,"y":80,"wires":[]},{"id":"f76267dc.b2aec8","type":"qlab out","z":"d1a5dd87.52da8","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z2_on}/start","name":"z2_on","x":1590,"y":200,"wires":[]},{"id":"f8bbfb83.b9b6f","type":"qlab out","z":"d1a5dd87.52da8","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z2_off}/start","name":"z2_off","x":1590,"y":240,"wires":[]},{"id":"68951166.17912","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1450,"y":220,"wires":[["f76267dc.b2aec8"],["f8bbfb83.b9b6f"]]},{"id":"c3b0febf.acc2e","type":"switch","z":"d1a5dd87.52da8","name":"Zone Filter","property":"payload.address","propertyType":"msg","rules":[{"t":"eq","v":"/zone1","vt":"str"},{"t":"eq","v":"/zone2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":620,"wires":[["41d8afd3.7073a8"],["c135475f.c8cfb8"]]},{"id":"3030843d.52338c","type":"comment","z":"d1a5dd87.52da8","name":"Qlab Message","info":"03/04/2020, 11:01:10node: 50361748.925e68\nmsg : Object\nobject\npayload: object\naddress: \"/zone1\"\nargs: array[1]\npacketInfo: object\naddress: \"10.1.1.54\"\nfamily: \"IPv4\"\nport: 51152\nsize: 16\n_msgid: \"fe3edea9.47053\"","x":100,"y":660,"wires":[]},{"id":"41d8afd3.7073a8","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload.args","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":560,"wires":[["89bc2fd2.e9deb8"],["523ba4f6.f70d64"]]},{"id":"89bc2fd2.e9deb8","type":"change","z":"d1a5dd87.52da8","name":"Change to 1 On","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":540,"wires":[["198fa66b.22a0b2"]]},{"id":"523ba4f6.f70d64","type":"change","z":"d1a5dd87.52da8","name":"Change to 0 Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":580,"wires":[["198fa66b.22a0b2"]]},{"id":"c135475f.c8cfb8","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload.args","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":680,"wires":[["f2f42bdd.12398"],["62370aa0.b5697c"]]},{"id":"f2f42bdd.12398","type":"change","z":"d1a5dd87.52da8","name":"Change to 1 On","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":660,"wires":[["e6fff1b4.416558"]]},{"id":"62370aa0.b5697c","type":"change","z":"d1a5dd87.52da8","name":"Change to 0 Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":700,"wires":[["e6fff1b4.416558"]]},{"id":"8c51e78f.a70ba8","type":"qlab out","z":"d1a5dd87.52da8","qlab":"30a2d5fe.6977f2","passcode":"","workspaceId":"","command":"/cue/{z1_off}/start","name":"z1_off","x":1590,"y":120,"wires":[]},{"id":"d99dbb45.d3a5d","type":"comment","z":"d1a5dd87.52da8","name":"Switch Inputs","info":"Switch Inputs from Rpi GPI pin 11 and 12","x":90,"y":20,"wires":[]},{"id":"20235117.77c57e","type":"comment","z":"d1a5dd87.52da8","name":"Message Handling","info":"","x":1150,"y":20,"wires":[]},{"id":"aae23899.9cc018","type":"comment","z":"d1a5dd87.52da8","name":"Indicator Switch","info":"","x":1340,"y":20,"wires":[]},{"id":"8cb32d03.4be3f","type":"comment","z":"d1a5dd87.52da8","name":"OSC Message to Qlab","info":"","x":1540,"y":20,"wires":[]},{"id":"a0594af5.fa5938","type":"comment","z":"d1a5dd87.52da8","name":"OSC received from Qlab","info":"","x":130,"y":480,"wires":[]},{"id":"dd70147e.00b2f8","type":"comment","z":"d1a5dd87.52da8","name":"Filter and message handling","info":"","x":440,"y":480,"wires":[]},{"id":"878e01e7.65d67","type":"comment","z":"d1a5dd87.52da8","name":"Indicator and manual switch","info":"","x":760,"y":480,"wires":[]},{"id":"5b89ef34.25355","type":"comment","z":"d1a5dd87.52da8","name":"GPO LEDs","info":"LED outputs GPIO 15 and 16","x":1430,"y":480,"wires":[]},{"id":"210e1e76.b4ef4a","type":"trigger","z":"d1a5dd87.52da8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":1220,"y":540,"wires":[["60aee7c2.1d2fb8","bf4019e5.152aa"]]},{"id":"60aee7c2.1d2fb8","type":"function","z":"d1a5dd87.52da8","name":"","func":"if (msg.payload == \"off\")\n\tcontext.state = 0;\nif (msg.payload == \"on\")\n\tcontext.state = 1;\n\nif (context.state == 1)\n{\n\tif (msg.payload == 0)\n\t\treturn msg;\n\telse\n\t\treturn;\n}\nelse\n\treturn;","outputs":1,"noerr":0,"x":1070,"y":600,"wires":[["3cb4c7c4.5a504"]]},{"id":"82e17e03.3daa08","type":"switch","z":"d1a5dd87.52da8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":560,"wires":[["60aee7c2.1d2fb8","210e1e76.b4ef4a"],["60aee7c2.1d2fb8"]]},{"id":"3cb4c7c4.5a504","type":"delay","z":"d1a5dd87.52da8","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":600,"wires":[["210e1e76.b4ef4a"]]},{"id":"219ef0db.fa0de","type":"trigger","z":"d1a5dd87.52da8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":1220,"y":660,"wires":[["840e9a19.4e35e","84cfa4eb.645fd8"]]},{"id":"840e9a19.4e35e","type":"function","z":"d1a5dd87.52da8","name":"","func":"if (msg.payload == \"off\")\n\tcontext.state = 0;\nif (msg.payload == \"on\")\n\tcontext.state = 1;\n\nif (context.state == 1)\n{\n\tif (msg.payload == 0)\n\t\treturn msg;\n\telse\n\t\treturn;\n}\nelse\n\treturn;","outputs":1,"noerr":0,"x":1070,"y":720,"wires":[["27c6a97c.e46c86"]]},{"id":"b77e0534.26689","type":"switch","z":"d1a5dd87.52da8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":910,"y":680,"wires":[["840e9a19.4e35e","219ef0db.fa0de"],["840e9a19.4e35e"]]},{"id":"27c6a97c.e46c86","type":"delay","z":"d1a5dd87.52da8","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":720,"wires":[["219ef0db.fa0de"]]},{"id":"ed0d0297.d1035","type":"comment","z":"d1a5dd87.52da8","name":"Blinking LED","info":"","x":1090,"y":480,"wires":[]},{"id":"a27fb31e.06bda","type":"link out","z":"76f61516.0cd434","name":"","links":["9e461472.dde588"],"x":1115,"y":160,"wires":[]},{"id":"9e461472.dde588","type":"link in","z":"76f61516.0cd434","name":"","links":["a27fb31e.06bda"],"x":155,"y":40,"wires":[["2e4f9089.367a5"]]},{"id":"12a2521.57ba52e","type":"rpi-gpio out","z":"d1a5dd87.52da8","name":"15-Sw1 LED","pin":"15","set":true,"level":"0","freq":"","out":"out","x":1450,"y":140,"wires":[]},{"id":"2ed1b06e.d1db3","type":"function","z":"d1a5dd87.52da8","name":"Rising Only (Toggle)","func":"var i=context.get('i') || 0;\nvar payload=msg.payload;\ncontext.set(\"i\",Math.abs(i-payload));\nmsg.payload=i;\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":100,"wires":[["17bbed50.a94c5b"]],"info":"https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=284357&sid=e3973749fd4c6596fbba38ffc79847c2\nchrisgal\n\nRe: Node Red toggle function\nQuote\nSun Dec 16, 2018 4:55 am\n\nA very simple function to use with a push button.\nState of button is send as input of function (msg.payload), 1 if pushing 0 if releasing.\nOutput of the function toggles between 0 and 1 when pushing the button, no change when releasing.\n\nvar i=context.get('i') || 0;\nvar payload=msg.payload;\ncontext.set(\"i\",Math.abs(i-payload));\nvar payload=msg.payload;\nmsg.payload=i;\nreturn msg;"},{"id":"2ba8df4f.3c5f8","type":"change","z":"d1a5dd87.52da8","name":"add timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    'state': payload,\t    'timestamp': $millis()\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":60,"wires":[["fe779f32.6f769"]]},{"id":"fe779f32.6f769","type":"join","z":"d1a5dd87.52da8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload.state","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":60,"wires":[["7c299b09.d945bc"]]},{"id":"7c299b09.d945bc","type":"change","z":"d1a5dd87.52da8","name":"Set Threshold","rules":[{"t":"set","p":"threshold","pt":"msg","to":"400","tot":"num"},{"t":"set","p":"delta","pt":"msg","to":"$lookup(payload, '0').timestamp - $lookup(payload, '1').timestamp","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"delta < threshold ? 'short' : 'long'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":60,"wires":[["36fb6004.987c8"]]},{"id":"2781db70.2dadfc","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":110,"y":60,"wires":[["35e57dd4.209742"],["d3e54cd9.76c62"]]},{"id":"35e57dd4.209742","type":"change","z":"d1a5dd87.52da8","name":"Set to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":40,"wires":[["2ba8df4f.3c5f8"]]},{"id":"d3e54cd9.76c62","type":"change","z":"d1a5dd87.52da8","name":"Set to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":80,"wires":[["2ba8df4f.3c5f8"]]},{"id":"36fb6004.987c8","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"long","vt":"str"},{"t":"eq","v":"short","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":60,"wires":[["f5c73ce4.cf821"],[]]},{"id":"f5c73ce4.cf821","type":"change","z":"d1a5dd87.52da8","name":"Set to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":60,"wires":[["403860b6.995f08"]]},{"id":"403860b6.995f08","type":"link out","z":"d1a5dd87.52da8","name":"","links":["bc4196c6.5320d"],"x":1075,"y":60,"wires":[]},{"id":"bc4196c6.5320d","type":"link in","z":"d1a5dd87.52da8","name":"","links":["403860b6.995f08"],"x":735,"y":120,"wires":[["2ed1b06e.d1db3"]]},{"id":"49bd81bb.6e71f","type":"function","z":"d1a5dd87.52da8","name":"Rising Only (Toggle)","func":"var i=context.get('i') || 0;\nvar payload=msg.payload;\ncontext.set(\"i\",Math.abs(i-payload));\nmsg.payload=i;\nreturn msg;","outputs":1,"noerr":0,"x":870,"y":220,"wires":[["3616661e.8f57c2"]],"info":"https://www.raspberrypi.org/forums/memberlist.php?mode=viewprofile&u=284357&sid=e3973749fd4c6596fbba38ffc79847c2\nchrisgal\n\nRe: Node Red toggle function\nQuote\nSun Dec 16, 2018 4:55 am\n\nA very simple function to use with a push button.\nState of button is send as input of function (msg.payload), 1 if pushing 0 if releasing.\nOutput of the function toggles between 0 and 1 when pushing the button, no change when releasing.\n\nvar i=context.get('i') || 0;\nvar payload=msg.payload;\ncontext.set(\"i\",Math.abs(i-payload));\nvar payload=msg.payload;\nmsg.payload=i;\nreturn msg;"},{"id":"3c251174.b69396","type":"change","z":"d1a5dd87.52da8","name":"add timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    'state': payload,\t    'timestamp': $millis()\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":180,"wires":[["24895674.7b4142"]]},{"id":"24895674.7b4142","type":"join","z":"d1a5dd87.52da8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload.state","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":180,"wires":[["31f403d3.56de14"]]},{"id":"31f403d3.56de14","type":"change","z":"d1a5dd87.52da8","name":"Set Threshold","rules":[{"t":"set","p":"threshold","pt":"msg","to":"400","tot":"num"},{"t":"set","p":"delta","pt":"msg","to":"$lookup(payload, '0').timestamp - $lookup(payload, '1').timestamp","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"delta < threshold ? 'short' : 'long'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":180,"wires":[["de636de2.d1561"]]},{"id":"c36d7470.053a2","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":110,"y":180,"wires":[["af32719d.3398d8"],["32ec2c37.0473d4"]]},{"id":"af32719d.3398d8","type":"change","z":"d1a5dd87.52da8","name":"Set to 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":160,"wires":[["3c251174.b69396"]]},{"id":"32ec2c37.0473d4","type":"change","z":"d1a5dd87.52da8","name":"Set to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":200,"wires":[["3c251174.b69396"]]},{"id":"de636de2.d1561","type":"switch","z":"d1a5dd87.52da8","name":"split","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"long","vt":"str"},{"t":"eq","v":"short","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":180,"wires":[["860f5c79.941128"],[]]},{"id":"860f5c79.941128","type":"change","z":"d1a5dd87.52da8","name":"Set to 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":180,"wires":[["cbab8095.576298"]]},{"id":"cbab8095.576298","type":"link out","z":"d1a5dd87.52da8","name":"","links":["24601cd3.afd474"],"x":1075,"y":180,"wires":[]},{"id":"24601cd3.afd474","type":"link in","z":"d1a5dd87.52da8","name":"","links":["cbab8095.576298"],"x":735,"y":240,"wires":[["49bd81bb.6e71f"]]},{"id":"d9aff087.39e93","type":"rpi-gpio out","z":"d1a5dd87.52da8","name":"16-Sw2 LED","pin":"16","set":true,"level":"0","freq":"","out":"out","x":1450,"y":260,"wires":[]},{"id":"354343d4.c9fa44","type":"comment","z":"76f61516.0cd434","name":"This flow can be used to calculate short and long presses from a GPIO pin, expects 1 or 0 as payload","info":"","x":370,"y":360,"wires":[]},{"id":"b101dc14.7e516","type":"inject","z":"76f61516.0cd434","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":420,"wires":[["15402923.afd457"]]},{"id":"c90fefda.fd8a3","type":"inject","z":"76f61516.0cd434","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":460,"wires":[["15402923.afd457"]]},{"id":"15402923.afd457","type":"change","z":"76f61516.0cd434","name":"Add timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    'state': payload,\t    'timestamp': $millis()\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":440,"wires":[["ff909085.e143d"]]},{"id":"ff909085.e143d","type":"join","z":"76f61516.0cd434","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload.state","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":440,"wires":[["c3858f4a.f05788"]]},{"id":"49c6ec9e.1d6cdc","type":"debug","z":"76f61516.0cd434","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1010,"y":440,"wires":[]},{"id":"daf417f4.a6ce58","type":"change","z":"76f61516.0cd434","name":"Process delta","rules":[{"t":"set","p":"threshold","pt":"msg","to":"400","tot":"num"},{"t":"set","p":"delta","pt":"msg","to":"$lookup(payload, '0').timestamp - $lookup(payload, '1').timestamp","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"delta < threshold ? 'short' : 'long'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":440,"wires":[["49c6ec9e.1d6cdc"]]},{"id":"c3858f4a.f05788","type":"switch","z":"76f61516.0cd434","name":"Filter negative","property":"$lookup(payload, '0').timestamp - $lookup(payload, '1').timestamp","propertyType":"jsonata","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":600,"y":440,"wires":[["daf417f4.a6ce58"]]},{"id":"d7d9c93f.ef354","type":"comment","z":"76f61516.0cd434","name":"Time treshold is set here","info":"","x":830,"y":480,"wires":[]}]

Flow Info

Created 4 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x35)
  • comment (x25)
  • debug (x1)
  • delay (x4)
  • exec (x3)
  • file (x2)
  • function (x8)
  • inject (x14)
  • join (x4)
  • link in (x3)
  • link out (x3)
  • switch (x26)
  • trigger (x4)
Other

Tags

  • Qlab
  • GPI
  • GPO
  • Switch
  • LED
  • Momentary
  • Latching
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option