Hello Guys i am new on node red and have a "Little" question about the function nodes.
I get mqtt Messages from an "Node MCU V3 Lolin", and put out a kind visualisation on the nodered/ui site. The whole System is a Raspberry Pi 3b+.
That works Pretty fine, the Messages come in an i can see the Values on Gauges an so on.
Now i would set an gpio Output on the raspi, if the Value (esp32/p10 and esp32/p25) under "50.00" the gpio Pin 11 must set true , if the Values over 50 Pin 11 must set false and Pin13 must set true, if the Value over "100.00" Pin 11,13 must be set false and Pin 15 to true.
I used a function node to test the Value readings and Change a text on the UI Site, this is sometimes working and sometimes not. In this case would say i must use a for while loop or someting else .
Anyone have an idea to get this thing working?
[{"id":"8d6fc00e.79c98","type":"tab","label":"Raumluftueberwachung Messungen","disabled":false,"info":""},{"id":"e5bbc414.047a58","type":"mqtt out","z":"8d6fc00e.79c98","name":"","topic":"esp32/output","qos":"","retain":"","broker":"ffe7b932.876ae8","x":270,"y":980,"wires":[]},{"id":"e25998fd.40c348","type":"mqtt in","z":"8d6fc00e.79c98","name":"","topic":"esp32/Temperatur","qos":"2","datatype":"auto","broker":"ffe7b932.876ae8","x":130,"y":401,"wires":[["94213d28.d3d4f","d9755720.400da8","9c962029.c6c61"]]},{"id":"f39fb428.731e38","type":"ui_switch","z":"8d6fc00e.79c98","name":"","label":"Output","tooltip":"","group":"47d4aadb.665534","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":129,"y":980,"wires":[["e5bbc414.047a58"]]},{"id":"94213d28.d3d4f","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":327,"y":368,"wires":[]},{"id":"49584a91.d303f4","type":"mqtt in","z":"8d6fc00e.79c98","name":"","topic":"esp32/Luftfeuchte","qos":"2","datatype":"auto","broker":"90edecf3.20888","x":130,"y":680,"wires":[["8c0db659.80f398","9e320ec4.ad1d6"]]},{"id":"8c0db659.80f398","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":317,"y":647,"wires":[]},{"id":"d9755720.400da8","type":"ui_chart","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":4,"width":0,"height":0,"label":"Temperatur","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"-10","ymax":"85","removeOlder":"12","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":327,"y":428,"wires":[[]]},{"id":"9e320ec4.ad1d6","type":"ui_gauge","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":6,"width":0,"height":0,"gtype":"gage","title":"Luftfeuchte","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#00b3d9","#0073e6","#001bd7"],"seg1":"33","seg2":"66","x":317,"y":707,"wires":[]},{"id":"1429e4bb.7620bb","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":330,"y":219,"wires":[]},{"id":"be7256b9.d02688","type":"ui_gauge","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":8,"width":0,"height":0,"gtype":"gage","title":"Partikel < 10 µg/m³","label":"µg/m³","format":"{{value}}","min":0,"max":"999","colors":["#00b3d9","#0073e6","#001bd7"],"seg1":"33","seg2":"66","x":330,"y":260,"wires":[]},{"id":"fc93c4ad.93b388","type":"mqtt in","z":"8d6fc00e.79c98","name":"","topic":"esp32/p10","qos":"0","datatype":"utf8","broker":"90edecf3.20888","x":120,"y":239,"wires":[["1429e4bb.7620bb","be7256b9.d02688","af4b8366.f8761","abb3ee6a.d6ce9"]]},{"id":"bb264d7c.3382f","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":330,"y":55,"wires":[]},{"id":"c828fe56.22d1","type":"ui_gauge","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":9,"width":0,"height":0,"gtype":"gage","title":"Partikel < 2.5 µg/m³","label":"µg/m³","format":"{{value}}","min":0,"max":"999","colors":["#00b3d9","#0073e6","#001bd7"],"seg1":"33","seg2":"66","x":350,"y":115,"wires":[]},{"id":"62551a23.54cc54","type":"mqtt in","z":"8d6fc00e.79c98","name":"","topic":"esp32/p25","qos":"2","datatype":"utf8","broker":"90edecf3.20888","x":120,"y":75,"wires":[["bb264d7c.3382f","c828fe56.22d1"]]},{"id":"70c662d3.84c96c","type":"mqtt in","z":"8d6fc00e.79c98","name":"","topic":"esp32/Luftdruck","qos":"2","datatype":"auto","broker":"90edecf3.20888","x":120,"y":560,"wires":[["188806c.3e99af9","d67d1b4e.910588"]]},{"id":"188806c.3e99af9","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":317,"y":527,"wires":[]},{"id":"d67d1b4e.910588","type":"ui_gauge","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":10,"width":0,"height":0,"gtype":"gage","title":"Luftdruck","label":"hPa","format":"{{value}}","min":"300","max":"1100","colors":["#00b3d9","#0073e6","#001bd7"],"seg1":"33","seg2":"66","x":307,"y":587,"wires":[]},{"id":"9f125332.13138","type":"mqtt in","z":"8d6fc00e.79c98","name":"","topic":"esp32/Hoehe","qos":"2","datatype":"auto","broker":"90edecf3.20888","x":114,"y":799,"wires":[["6d4b7a6b.c460c4","a977a0b6.b46a1"]]},{"id":"6d4b7a6b.c460c4","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":321,"y":766,"wires":[]},{"id":"a977a0b6.b46a1","type":"ui_gauge","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":11,"width":0,"height":0,"gtype":"gage","title":"Berechnete Höhe","label":"m","format":"{{value}}","min":0,"max":"999","colors":["#00b3d9","#0073e6","#001bd7"],"seg1":"33","seg2":"66","x":341,"y":826,"wires":[]},{"id":"9c962029.c6c61","type":"ui_gauge","z":"8d6fc00e.79c98","name":"","group":"47d4aadb.665534","order":2,"width":0,"height":0,"gtype":"gage","title":"Temperatur","label":"°C","format":"{{value}}","min":"-40","max":"85","colors":["#00b3d9","#0073e6","#001bd7"],"seg1":"33","seg2":"66","x":330,"y":480,"wires":[]},{"id":"af4b8366.f8761","type":"function","z":"8d6fc00e.79c98","name":"Feinstaubalarm","func":"var feinstaubalarm;\nfeinstaubalarm = \"gut\";\nmsg.color=\"limegreen\";\n\n\nif (msg.payload > \"50.01\"){\n feinstaubalarm = \"maessig\";\n msg.color=\"orange\";}\nelse if (msg.payload > \"99.99\"){\n feinstaubalarm = \"ungesund\";\n msg.color=\"red\";}\n\nmsg.payload = feinstaubalarm;\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":300,"wires":[["eae6aaa4.888078","ccc03a4f.f658f8"]]},{"id":"ccc03a4f.f658f8","type":"ui_text","z":"8d6fc00e.79c98","group":"47d4aadb.665534","order":14,"width":0,"height":0,"name":"","label":"Luftgüte ist","format":"{{msg.payload}}","layout":"row-center","x":740,"y":340,"wires":[]},{"id":"eae6aaa4.888078","type":"debug","z":"8d6fc00e.79c98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":720,"y":300,"wires":[]},{"id":"36456a18.535206","type":"function","z":"8d6fc00e.79c98","name":"case Feinstaub","func":"var feinstaubalarm;\n\nswitch(feinstaubalarm)\n{\ncase 1: \n input(msg.payload >= \"51.00\")\n feinstaubalarm = \"maessig\"\n msg.color=\"orange\"\n break;\n \ncase 2: \n input(msg.payload >= \"101.00\")\n feinstaubalarm = \"ungesund\"\n msg.color=\"red\"\n break;\ncase 3:\n input(msg.payload <= \"50.00\")\n feinstaubalarm = \"gut\"\n msg.color=\"green\"\n break;\n}\nmsg.payload = feinstaubalarm;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":180,"wires":[[]]},{"id":"5385b197.db6ea","type":"rpi-gpio out","z":"8d6fc00e.79c98","name":"","pin":"11","set":"","level":"0","freq":"","out":"out","x":690,"y":460,"wires":[]},{"id":"63c214b9.26a92c","type":"rpi-gpio out","z":"8d6fc00e.79c98","name":"","pin":"13","set":"","level":"0","freq":"","out":"out","x":690,"y":520,"wires":[]},{"id":"a7def52f.8ab178","type":"rpi-gpio out","z":"8d6fc00e.79c98","name":"","pin":"15","set":"","level":"0","freq":"","out":"out","x":690,"y":580,"wires":[]},{"id":"8253cc8d.1c4aa","type":"ui_switch","z":"8d6fc00e.79c98","name":"","label":"Green","tooltip":"","group":"47d4aadb.665534","order":15,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":520,"y":460,"wires":[["5385b197.db6ea"]]},{"id":"13107f59.208a01","type":"ui_switch","z":"8d6fc00e.79c98","name":"","label":"Yellow","tooltip":"","group":"47d4aadb.665534","order":16,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":520,"y":540,"wires":[["63c214b9.26a92c"]]},{"id":"902fdd43.be21b","type":"ui_switch","z":"8d6fc00e.79c98","name":"","label":"Red","tooltip":"","group":"47d4aadb.665534","order":17,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":520,"y":600,"wires":[["a7def52f.8ab178"]]},{"id":"3cf546ef.c4692a","type":"function","z":"8d6fc00e.79c98","name":"if change","func":"var x = msg.payload[8];\nif (x<=\"50.01\") {\n var msg_o = {payload :\"gut\"}\n} else{\n var masg_o = {payload :\"maessig\"}\n}\nreturn msg_o;","outputs":1,"noerr":0,"x":550,"y":120,"wires":[[]]},{"id":"abb3ee6a.d6ce9","type":"switch","z":"8d6fc00e.79c98","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"50.00","vt":"num"},{"t":"gt","v":"50","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":380,"wires":[["8253cc8d.1c4aa"],[]]},{"id":"ffe7b932.876ae8","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"47d4aadb.665534","type":"ui_group","z":"","name":"Übersicht Messwerte","tab":"9a849a30.7f97a8","disp":true,"width":6,"collapse":false},{"id":"90edecf3.20888","type":"mqtt-broker","z":"","name":"","broker":"192.168.2.110","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9a849a30.7f97a8","type":"ui_tab","z":"","name":"Raumluftüberwachung FSAT17","icon":"dashboard","disabled":false,"hidden":false}]