Hello all,
I am a complete newbie to all things node red.... through a bunch of trial and error I have managed to set up a rasberry pi as a mosquitto server and node red server and have two working flows on my network but really do not totally understand node red.
I am trying to compare two dallas temp sensor outputs.... one for my hot tubs temp and one for my solar water heater panel. I want the solar pump to turn on when its temp is more than 10 degrees over the hot tubs temp.
I have searched and thought I had the fix with the attached flow using a function with an if than but find that I think I am having trouble with the dallas temp sensors out put which shows a a string using a debug node. Searching online I found a few examples of using a function node and parseInt of the message two make it an interger so i can numerically compare the two values.
Part of my problem is that I am really not a coder and have little experiance with all of this.
I also dont understand a lot of what this forum is discussing again total newbie.
I have searched for tutorials and this forum and find some similar posts about comparing inside and outside temperatures for a whole house fan which seems very similar to what I am trying to do.
but when I try to impliment the fix the poster used I cannot seem to get it to work and my uneducated guess is that while the parseInt() is supposed to out put the message to an integer it is either not doing that or the function as I have it set up is not able to read the interger to check it against the other temp reading which is also an interger. The if function is alway false yielding "off" and even when the solar temp sensor reading is more than 10 higher than the spatemp it remains false.
I am sure it is something stupid that I just dont understand yet so hopefully someone on the forum can have a look at the flow example and give me a little help and education.
Thanks for anyone who takes the time to have a look to help this newbie.
Troy
[{"id":"5e71878b.7bf938","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"aba4afb.1ea9c5","type":"mqtt in","z":"5e71878b.7bf938","name":"","topic":"esp8266spa/spatemp","qos":"2","datatype":"auto","broker":"562eb1ef.1c2f1","x":160,"y":340,"wires":[["c9f12235.3cecf","f3f65772.66c258"]]},{"id":"e5a61cf2.8c672","type":"mqtt in","z":"5e71878b.7bf938","name":"","topic":"esp8266spa/solartemp","qos":"2","datatype":"auto","broker":"562eb1ef.1c2f1","x":120,"y":480,"wires":[["e34726a0.201d88","486f095c.d5c1f8"]]},{"id":"e34726a0.201d88","type":"debug","z":"5e71878b.7bf938","name":"tutu","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":410,"y":620,"wires":},{"id":"c9f12235.3cecf","type":"debug","z":"5e71878b.7bf938","name":"tutu1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":340,"wires":},{"id":"f3f65772.66c258","type":"function","z":"5e71878b.7bf938","name":"to int","func":"msg.payload=Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":380,"wires":[["51b6a281.39ac4c"]]},{"id":"d828674e.c50c38","type":"debug","z":"5e71878b.7bf938","name":"tutu2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":440,"wires":},{"id":"486f095c.d5c1f8","type":"function","z":"5e71878b.7bf938","name":"to int","func":"msg.payload=Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":500,"wires":[["51b6a281.39ac4c"]]},{"id":"51b6a281.39ac4c","type":"function","z":"5e71878b.7bf938","name":"Comparatore","func":"// this is passed a payload which is an object with\n// properties outside_temp and inside_temp\nif (msg.payload.solartemp > msg.payload.spatemp+10) {\n msg.payload = "on";\n} else\n{\n msg.payload = "off";\n}\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":440,"wires":[["d828674e.c50c38"]]},{"id":"562eb1ef.1c2f1","type":"mqtt-broker","z":"","name":"","broker":"192.168.250.8","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]