Hello. Im having difficulties converting data i think. node named "juhtimine" does not output numbers as i think it should. I have no previous experiences with javascript.
Heres the flow, i hope real programmers understand what i want to do in this flow.
[{"id":"417c5761.10e258","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"93185b2c.d53f18","type":"mqtt in","z":"417c5761.10e258","name":"Avamise temp","topic":"automaatika/MisTempAvab_KeskmineTuba","qos":"2","datatype":"json","broker":"d4c6732f.76e66","x":110,"y":300,"wires":[["383a4d55.ad099a"]]},{"id":"83b8cce1.4807f","type":"mqtt in","z":"417c5761.10e258","name":"Sulgemise temp","topic":"automaatika/MisTempSulgeb_KeskmineTuba","qos":"2","datatype":"auto","broker":"d4c6732f.76e66","x":120,"y":220,"wires":[["341f6b74.208cf4"]]},{"id":"5bd5877e.9a4e88","type":"mqtt in","z":"417c5761.10e258","name":"Autom.liigutamineON/OFF","topic":"automaatika/onoff_keskminetuba","qos":"2","datatype":"utf8","broker":"d4c6732f.76e66","x":150,"y":260,"wires":[["721c684a.b1712"]]},{"id":"cbab4b9a.574e9","type":"debug","z":"417c5761.10e258","name":"automaatika","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":280,"wires":[]},{"id":"341f6b74.208cf4","type":"function","z":"417c5761.10e258","name":"Sulgemistemp","func":"var x = (msg.payload);\nvar y = {sulgemisetemp: x};\nreturn {payload : y}","outputs":1,"noerr":0,"x":300,"y":220,"wires":[["cbab4b9a.574e9","b98337a5.8a2928"]]},{"id":"383a4d55.ad099a","type":"function","z":"417c5761.10e258","name":"Avamistemp","func":"var x = (msg.payload);\nvar y = {avamistemp: x};\nreturn {payload : y}","outputs":1,"noerr":0,"x":270,"y":300,"wires":[["cbab4b9a.574e9","b98337a5.8a2928"]]},{"id":"dd1b0553.141df","type":"mqtt in","z":"417c5761.10e258","name":"Temp","topic":"keskmine_tuba/temp","qos":"2","datatype":"json","broker":"d4c6732f.76e66","x":90,"y":60,"wires":[["3acff23d.60ffe6"]]},{"id":"3acff23d.60ffe6","type":"function","z":"417c5761.10e258","name":"Temp","func":"var x = (msg.payload);\nvar y = {temp: x};\nreturn {payload : y}","outputs":1,"noerr":0,"x":270,"y":60,"wires":[["cbab4b9a.574e9","b98337a5.8a2928"]]},{"id":"b98337a5.8a2928","type":"function","z":"417c5761.10e258","name":"juhtimine","func":"//if(msg.payload.lyliti == \"ON\"){\nvar temp = (msg.payload.temp);\nvar a = (msg.payload.lyliti);\nvar b = (msg.payload.sulgemistemp);\nvar c = (msg.payload.avamistemp);\nreturn {payload : b} //for debug purposes\n\n if(temp <= b && a == \"ON\"){\nreturn {payload : 0}\n} \n if(temp >= c && a == \"ON\"){\nreturn {payload : 1}\n} \n","outputs":1,"noerr":0,"x":560,"y":220,"wires":[["6803468.c8df5b8","6d7f7ab7.95854c"]]},{"id":"721c684a.b1712","type":"function","z":"417c5761.10e258","name":"lyliti","func":"var x = (msg.payload);\nvar y = {lyliti: x};\nreturn {payload : y}","outputs":1,"noerr":0,"x":330,"y":260,"wires":[["cbab4b9a.574e9","b98337a5.8a2928"]]},{"id":"6803468.c8df5b8","type":"debug","z":"417c5761.10e258","name":"juhtimine","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":760,"y":260,"wires":[]},{"id":"6d7f7ab7.95854c","type":"mqtt out","z":"417c5761.10e258","name":"akna juhtimine","topic":"suur_tuba/juhtimine","qos":"","retain":"","broker":"d4c6732f.76e66","x":780,"y":220,"wires":[],"info":"# ## 1"},{"id":"bdbec942.f3295","type":"comment","z":"417c5761.10e258","name":"these 3 mqtt subscriptions are retained messages from openhab, messages will receive here but \"juhtimine\" wil output error \"NaN\" after outputting variablesl ","info":"","x":560,"y":180,"wires":[]},{"id":"d4c6732f.76e66","type":"mqtt-broker","z":"","name":"localhost","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]