Template node does not show 1 value out of 5

Hi,
I can not find the reason why template node do not accept one payload from payload object (msg.payload.PS1). This works fine on other my template nodes and I can not distinguish difference from other payload objects..
Flow scenario is to receive Json array, then do some formatting and calculations and then pass them to the template widget for display.
Here goes my flow.

[{"id":"6873b9d5.171058","type":"ui_template","z":"d3b64754.5c4178","group":"e1180108.00e0e","name":"Solar","order":6,"width":"2","height":"2","format":"\n<md-button class=\"filled touched bigfont rounded vibrate\" style=\"background-color:#f1c40f\" ng-click=\"send({payload: 'Hello World'})\"> \n    <i class=\"fa fa-sun-o fa-2x\" style=\"color:{{msg.payload.Trend}}\"></i>\n    &nbsp&nbsp{{msg.payload.T1 || '?'}}&#176C<br/><br/>{{msg.payload.T3 || '?'}}&brvbar{{msg.payload.T2 || '?'}}&brvbar{{msg.payload.PS1 || '?'}}\n</md-button> \n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":790,"y":1000,"wires":[[]]},{"id":"65d3aa70.c75084","type":"debug","z":"d3b64754.5c4178","name":"TestX","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":1200,"wires":[]},{"id":"91b4dd06.5409b","type":"delay","z":"d3b64754.5c4178","name":"Delay 2 minutes","pauseType":"delay","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":680,"y":1140,"wires":[["b2a413fa.7d8df"]]},{"id":"8b43acab.69906","type":"function","z":"d3b64754.5c4178","name":"","func":"var hum_outside = flow.get('hum_outside');\nvar hum_shower = flow.get('hum_shower');\nvar sensor = msg.sensor;\nvar delta = 0.5; //set to the desired threshold level\n\nswitch(sensor){\n    case \"outside\":\n        flow.set(\"hum_outside\", msg.payload);\n        break\n        \n    case \"shower\":\n        flow.set(\"hum_shower\", msg.payload);\n        break\n}\n\nif (hum_shower < hum_outside - delta){ // shower-pirms\n    msg.payload = \"#c0392b\"; //oranzs\n}\nelse if (hum_outside < hum_shower - delta){\n    msg.payload = \"#3498DB\"; //zils\n}\nelse{\n    msg.payload = \"#FFFFFF\"; //balts\n}\n\nnode.status({\n\ttext : \"pirms: \"+hum_shower.toString()+' '+\"tagad: \"+hum_outside.toString()\n});\nmsg.topic = \"Trend\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1080,"y":1140,"wires":[["afecc3c6.e48ba"]]},{"id":"c4ff81bc.4cfb1","type":"change","z":"d3b64754.5c4178","name":"","rules":[{"t":"set","p":"sensor","pt":"msg","to":"outside","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1080,"wires":[["8b43acab.69906"]]},{"id":"b2a413fa.7d8df","type":"change","z":"d3b64754.5c4178","name":"","rules":[{"t":"set","p":"sensor","pt":"msg","to":"shower","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1140,"wires":[["8b43acab.69906"]]},{"id":"e9cefc65.4e072","type":"function","z":"d3b64754.5c4178","name":"","func":"var T1=msg.payload.T1;\nvar T11=0.000009*Math.pow(T1, 2)+0.1027*T1-216.25;\nT11=Math.round(T11);\nT11={payload: T11, topic: \"T1\"};\nvar T2=msg.payload.T2;\nvar T22=-0.000000000002*Math.pow(T2, 4)+0.00000001*Math.pow(T2, 3)-0.00004*Math.pow(T2, 2)+0.0762*T2-4.3067;\nT22=Math.round(T22);\nT22={payload: T22, topic: \"T2\"};\nvar T3=msg.payload.T3;\nvar T33=0.0251*T3 + 8.9619;\nT33=Math.round(T33);\nT33={payload: T33, topic: \"T3\"};\nvar PS=msg.payload.PS;\n\nif (PS = 0){ \n    var PS1={payload: \"x\", topic: \"PS1\"};\n}\nelse{\n    var PS1=PS/4095*100;\nPS1=Math.round(PS1);\nPS1={payload: PS1, topic: \"PS1\"};\n}\nreturn [T11, T22, T33, PS1];","outputs":4,"noerr":0,"initialize":"","finalize":"","x":400,"y":1000,"wires":[["afecc3c6.e48ba","c4ff81bc.4cfb1","91b4dd06.5409b"],["afecc3c6.e48ba"],["afecc3c6.e48ba"],["afecc3c6.e48ba"]]},{"id":"afecc3c6.e48ba","type":"join","z":"d3b64754.5c4178","name":"Join","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"5","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":960,"wires":[["6873b9d5.171058","65d3aa70.c75084"]]},{"id":"8e3eb39b.de6c8","type":"inject","z":"d3b64754.5c4178","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"SRS258","payload":"{\"T1\":1864,\"T2\":683,\"T3\":2382,\"PS\":100}","payloadType":"json","x":80,"y":1080,"wires":[["e9cefc65.4e072"]]},{"id":"e1180108.00e0e","type":"ui_group","name":"Kopsavilkums","tab":"515653b0.668b0c","order":1,"disp":false,"width":"6","collapse":false},{"id":"515653b0.668b0c","type":"ui_tab","name":"Home","icon":"local_grocery_store","order":2,"disabled":false,"hidden":false}]

Easier for people to read if you include the code of the template itself. Many people wont want to load a flow just to check it out.

Hi, I apologize. My guess that the problem reason might be beyond template node itself that is why i put the complete flow.

The first function node is confusing to me, but this line:

if (PS = 0){

will always validate to true. If you want to compare, at the very least you need to use: ==, but I would recommend ===.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.