Hey, I want to extract temperature and sate from the two individual mqtt nodes and put it to a variable for an if condition.
[{"id":"e138bfbf.d608d","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"681e26cb.94af38","type":"mqtt in","z":"e138bfbf.d608d","name":"","topic":"ac_humidity","qos":"2","broker":"4c91647e.b969fc","x":210,"y":1020,"wires":[["feb1b16d.72fc1"]]},{"id":"4d44d983.912fd8","type":"mqtt in","z":"e138bfbf.d608d","name":"","topic":"inside_temp","qos":"2","broker":"4c91647e.b969fc","x":210,"y":1080,"wires":[["feb1b16d.72fc1"]]},{"id":"ba56540a.e134c8","type":"mqtt in","z":"e138bfbf.d608d","name":"","topic":"ac_state","qos":"2","broker":"4c91647e.b969fc","x":520,"y":960,"wires":[["feb1b16d.72fc1"]],"outputLabels":["ac_state"]},{"id":"feb1b16d.72fc1","type":"delay","z":"e138bfbf.d608d","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":960,"wires":[["932a89c.a1acb78"]]},{"id":"932a89c.a1acb78","type":"function","z":"e138bfbf.d608d","name":"","func":"var msg3 = msg.payload.temp_c ;\n\ncontext.data = context.data || {};\n\nvar msg1 = { payload:context.data.inside_temp };\nvar ac_state = { payload:context.data.ac_state };\n\n//var msg1 = msg.payload.inside_temp ;\n\n//var ac_state = msg.payload.ac_state ;\n\nvar lowthresholdtemp = msg3 - 4;\nvar highthresholdtemp = msg3 + 4;\n\nif (ac_state == \"ON\") {\n\n if (lowthresholdtemp <= msg1 || msg1 <= highthresholdtemp) { // Use sensor value instead of 25\n msg.payload =\"Not Cooling.\";\n return msg;\n } else {\n return null;\n }\n}","outputs":1,"noerr":0,"x":910,"y":960,"wires":[["6996833c.c22b8c"]]},{"id":"6996833c.c22b8c","type":"debug","z":"e138bfbf.d608d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1110,"y":960,"wires":[]},{"id":"53a7ecc.378fc14","type":"http request","z":"e138bfbf.d608d","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://api.weatherunlocked.com/api/current/6.8652,79.8599?app_id=970d4958&app_key=79c1ac7e6d18a960b017cd15eb35bfa0","tls":"","proxy":"","authType":"basic","x":770,"y":660,"wires":[[]]},{"id":"4165a85c.516248","type":"inject","z":"e138bfbf.d608d","name":"","topic":"","payload":"","payloadType":"date","repeat":"300","crontab":"","once":true,"onceDelay":"0.1","x":550,"y":660,"wires":[["53a7ecc.378fc14"]]},{"id":"afece970.5e8838","type":"function","z":"e138bfbf.d608d","name":"","func":"if (msg.payload==\"Error: getaddrinfo ENOTFOUND api.weatherunlocked.com api.weatherunlocked.com:80\"){\nreturn null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":880,"wires":[["feb1b16d.72fc1"]]},{"id":"ec944499.e4fe58","type":"http request","z":"e138bfbf.d608d","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://api.weatherunlocked.com/api/current/6.8652,79.8599?app_id=970d4958&app_key=79c1ac7e6d18a960b017cd15eb35bfa0","tls":"","proxy":"","authType":"basic","x":720,"y":740,"wires":[["afece970.5e8838"]]},{"id":"b372c91.940ac38","type":"inject","z":"e138bfbf.d608d","name":"","topic":"","payload":"","payloadType":"date","repeat":"300","crontab":"","once":true,"onceDelay":"0.1","x":500,"y":740,"wires":[["ec944499.e4fe58"]]},{"id":"4c91647e.b969fc","type":"mqtt-broker","z":"","name":"","broker":"85.119.83.194","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]
The output of inside_temp-
inside_temp : msg.payload : string[5]
" 30.5"