Advertisement
smort

BFnode

May 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. [{"id":"b875ee30.c832a","type":"tab","label":"Brewfather","disabled":false,"info":""},{"id":"415da8a3.e66638","type":"http in","z":"b875ee30.c832a","name":"","url":"/brewfather","method":"post","upload":false,"swaggerDoc":"","x":80,"y":20,"wires":[["7d6a6687.0b59a8","10343411.3bdc44","aa6f2be3.727528"]]},{"id":"7d6a6687.0b59a8","type":"function","z":"b875ee30.c832a","name":"BF to BC","func":"flow.set('recipe' , msg.payload.recipe.fermentation)\nflow.set('fbeername' , msg.payload.recipe.name)\n\n\nfunction time_convert(num)\n { \n var hours = Math.floor(num / 60); \n var minutes = num % 60;\n return + hours + \":\" + minutes + \":00\"; \n}\n\nvar hopstand\nvar hopstandtemp\nif (msg.payload.recipe.hopStandMinutes > 0) {\n hopstand = true\n hopstandtemp = msg.payload.recipe.avgWeightedHopstandTemp\n}\nelse {\n hopstandtemp = 0\n hopstand = false\n}\n\nvar firstwort\nif (msg.payload.recipe.hops[0].use == \"First Wort\") {\n firstwort = true\n} \nelse {\n firstwort = false\n}\n\n\nvar hoptime=[];\nfor(var x=0;x<msg.payload.boilStepsCount;x++){\n hoptime[x]= msg.payload.recipe.hops[x].time;\n }\nhoptime.push(0,0,0,0,0,0,0,0,0,0);\nhoptime.length = 10\n\nvar mashtime=[];\nfor(var y=0;y<msg.payload.mashStepsCount;y++){\n mashtime[y]= msg.payload.recipe.mash.steps[y].stepTime;\n }\nmashtime.push(0,0,0,0,0);\nmashtime.length = 5\n\nvar mashsteps = msg.payload.mashStepsCount - 1;\nvar mashtemp=[];\nfor(var z=0;z<msg.payload.mashStepsCount;z++){\n mashtemp[z]= msg.payload.recipe.mash.steps[z].stepTemp;\n }\nmashtemp.push(mashtemp[mashsteps], mashtemp[mashsteps], mashtemp[mashsteps], mashtemp[mashsteps], mashtemp[mashsteps], mashtemp[mashsteps])\nmashtemp.length = 6\n\nmsg.payload = [ \n\n{ \"Name\": \"Preboil volume\", \"Value\": msg.payload.recipe.boilSize } , \n{ \"Name\": \"Sparge volume\" , \"Value\": msg.payload.recipe.data.spargeWaterAmount } , \n{ \"Name\": \"Strike temp\" , \"Value\": msg.payload.recipe.data.strikeTemp } , \n{ \"Name\": \"Mash temp\" , \"Value\": mashtemp[0] } ,\n{ \"Name\": \"Mash temp1\" , \"Value\": mashtemp[1] } , \n{ \"Name\": \"Mash temp2\" , \"Value\": mashtemp[2] } ,\n{ \"Name\": \"Mash temp3\" , \"Value\": mashtemp[3] } ,\n{ \"Name\": \"Mash temp4\" , \"Value\": mashtemp[4] } ,\n{ \"Name\": \"Mash temp5\" , \"Value\": mashtemp[5] } ,\n{ \"Name\": \"Mash time1\" , \"Value\": time_convert(mashtime[0]) } ,\n{ \"Name\": \"Mash time2\" , \"Value\": time_convert(mashtime[1]) } ,\n{ \"Name\": \"Mash time3\" , \"Value\": time_convert(mashtime[2]) } ,\n{ \"Name\": \"Mash time4\" , \"Value\": time_convert(mashtime[3]) } ,\n{ \"Name\": \"Mash time5\" , \"Value\": time_convert(mashtime[4]) } ,\n{ \"Name\": \"Hop time0\" , \"Value\": time_convert(hoptime[0]) } ,\n{ \"Name\": \"Hop time1\" , \"Value\": time_convert(hoptime[1]) } ,\n{ \"Name\": \"Hop time2\" , \"Value\": time_convert(hoptime[2]) } ,\n{ \"Name\": \"Hop time3\" , \"Value\": time_convert(hoptime[3]) } ,\n{ \"Name\": \"Hop time4\" , \"Value\": time_convert(hoptime[4]) } ,\n{ \"Name\": \"Hop time5\" , \"Value\": time_convert(hoptime[5]) } ,\n{ \"Name\": \"Hop time6\" , \"Value\": time_convert(hoptime[7]) } ,\n{ \"Name\": \"Hop time8\" , \"Value\": time_convert(hoptime[8]) } ,\n{ \"Name\": \"Hop time9\" , \"Value\": time_convert(hoptime[9]) } ,\n{ \"Name\": \"Boil time\" , \"Value\": time_convert(msg. payload.recipe.boilTime) } ,\n{ \"Name\": \"Hopstand temp\" , \"Value\": hopstandtemp } ,\n{ \"Name\": \"First wort\" , \"Value\": firstwort } ,\n{ \"Name\": \"Recipe received\" , \"Value\": msg.payload._timestamp } ,\n{ \"Name\": \"Status\" , \"Value\": msg.payload.recipe.name }\n\n];\n\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":20,"wires":[["72236c7c.855b24"]]},{"id":"72236c7c.855b24","type":"http request","z":"b875ee30.c832a","name":"","method":"PUT","ret":"txt","paytoqs":false,"url":"http://192.168.77.246:8000/globals","tls":"","proxy":"","authType":"basic","x":530,"y":20,"wires":[[]]},{"id":"58479622.81d7a","type":"http in","z":"b875ee30.c832a","name":"","url":"/Fermenter","method":"get","upload":false,"swaggerDoc":"","x":80,"y":60,"wires":[["a021ade4.3d4dd"]]},{"id":"aa6f2be3.727528","type":"http response","z":"b875ee30.c832a","name":"","statusCode":"200","headers":{},"x":520,"y":60,"wires":[]},{"id":"a021ade4.3d4dd","type":"function","z":"b875ee30.c832a","name":"Fermenter","func":"msg.payload = [flow.get('recipe'),flow.get('fbeername')]\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":60,"wires":[["aa6f2be3.727528"]]},{"id":"db6d2933.986498","type":"tcp in","z":"b875ee30.c832a","name":"F1","server":"server","host":"","port":"8886","datamode":"single","datatype":"utf8","newline":"","topic":"","base64":false,"x":50,"y":140,"wires":[["f254039a.b45ca"]]},{"id":"f254039a.b45ca","type":"json","z":"b875ee30.c832a","name":"","property":"payload","action":"obj","pretty":false,"x":170,"y":140,"wires":[["bbbd6559.b57ea8"]]},{"id":"78bf8af.bb367f4","type":"switch","z":"b875ee30.c832a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"},{"t":"istype","v":"string","vt":"string"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":140,"wires":[["bd311b25.cb8b78"],["9ce2e10e.bce7f8"]]},{"id":"bbbd6559.b57ea8","type":"split","z":"b875ee30.c832a","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":290,"y":140,"wires":[["78bf8af.bb367f4"]]},{"id":"32d2dc09.6f275c","type":"debug","z":"b875ee30.c832a","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":220,"wires":[]},{"id":"b70b3cf5.3979a","type":"inject","z":"b875ee30.c832a","name":"Fusion config","topic":"fusion-configuration","payload":"{\"outputTopic\":\"F1\",\"inputTopics\":[\"beer\",\"name\",\"temp\",\"ext_temp\",\"temp_unit\",\"pressure\",\"pressure_unit\",\"gravity\",\"temperature\"],\"allowUndefined\":true,\"onlyPayloads\":true}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":"2","x":440,"y":100,"wires":[["9ce2e10e.bce7f8"]]},{"id":"9ce2e10e.bce7f8","type":"fusion","z":"b875ee30.c832a","name":"","x":670,"y":140,"wires":[["2015c268.6509ce","32d2dc09.6f275c"]]},{"id":"bd311b25.cb8b78","type":"aggregator","z":"b875ee30.c832a","name":"median","topic":"","intervalCount":"6","intervalUnits":"s","submitIncompleteInterval":true,"submitPerTopic":true,"aggregationType":"median","x":540,"y":140,"wires":[["9ce2e10e.bce7f8"]]},{"id":"2015c268.6509ce","type":"delay","z":"b875ee30.c832a","name":"limit","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":790,"y":140,"wires":[["32d2dc09.6f275c"]]},{"id":"5d5351ea.508d8","type":"tcp in","z":"b875ee30.c832a","name":"iSpindel_1","server":"server","host":"","port":"8891","datamode":"single","datatype":"utf8","newline":"","topic":"","base64":false,"x":55,"y":295,"wires":[[]]},{"id":"30b9ab62.bdbd04","type":"tcp in","z":"b875ee30.c832a","name":"iSpindel_2","server":"server","host":"","port":"8892","datamode":"single","datatype":"utf8","newline":"","topic":"","base64":false,"x":60,"y":340,"wires":[[]]},{"id":"665fd1e3.52fb6","type":"tcp in","z":"b875ee30.c832a","name":"iSpindel_3","server":"server","host":"","port":"8893","datamode":"single","datatype":"utf8","newline":"","topic":"","base64":false,"x":60,"y":380,"wires":[[]]},{"id":"10343411.3bdc44","type":"debug","z":"b875ee30.c832a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":190,"y":220,"wires":[]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement