Can't processing False & True values comes from mqtt broker

I can't see debug node False, True values with bottom function, I can see only floatig values

for(var i in msg.payload.values)
{
var newmessage = msg.payload.values[i].v;
var newtopic = msg.topic + '/' + msg.payload.values[i].id;
node.send({ payload:newmessage, topic:newtopic });
}

return msg;

You don't give us much to go on. For example, the source data.

Also you are using both node.send and return msg - it is very likely that the return msg will happen before the node.send msgs.

1 Like

Thanks for express answer

My source data like this [{"id":"HSM1.EGD.CAX.ECAX1.C00001_00013_M00049","v":false,"q":true,"t":1569486884539},

Best regards

And the actual debug output?

Works fine for me. So what exactly do you see?

You don't add "q" to the new message so you won't see q in your debug for the messages that come via node.send

{"timestamp":1569491883539,"values":[{"id":"HSM1.EGD.CAX.ECAX1.C00001_00018_R00001","v":20.8999996,"q":true,"t":1569491873617},{"id":"HSM1.EGD.CMS.ECERD.CMMAIN/DRIVE/ODA/TmpGn_FB","v":21.5,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.ECLINV/RTD/RTD3/TEMP_IA","v":33.3999977,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.ECLINV/RTD/RTD5/TEMP_IA","v":35.8999977,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.ECLINV/RTD/RTD4/TEMP_IA","v":32.1999969,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.SMCLCV/RTD/RTD3/TEMP_IA","v":32,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.SMCLCV/RTD/RTD2/TEMP_IA","v":34.1999969,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.SMCLCV/RTD/RTD6/TEMP_IA","v":32.6999969,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.SMCLCV/RTD/RTD4/TEMP_IA","v":34,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SMS.ESERD.XCLINV/RTD/RTD2/TEMP_IA","v":36,"q":true,"t":1569491873617},{"id":"HSM1.EGD.SPR.SM/DC2000/ODAKUZ_FB","v":21.9999981...

Thats the output from your return msg; line which as @TotallyInformationhas already suggested you remove

I was remove return msg; as @TotallyInformationhas suggested but i have an fault.

Here is my code

[{"id":"4ef988a0.0b4b48","type":"tab","label":"YKS_HSM","disabled":false,"info":""},{"id":"cf68ed3d.0110c","type":"mqtt in","z":"4ef988a0.0b4b48","name":"mqqt broker","topic":"iotgateway/#","qos":"1","datatype":"auto","broker":"7ea52760.c63ad8","x":243.0142059326172,"y":348.00567626953125,"wires":[["3f3ac09c.ddccf"]]},{"id":"8c301cf7.9daa1","type":"switch","z":"4ef988a0.0b4b48","name":"","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"HSM1.EGD.CMS.ECMS1.C00008_00041_M00035","vt":"str"},{"t":"cont","v":"HSM1.EGD.CMS.ECMS1.C00008_00041_M00036","vt":"str"},{"t":"cont","v":"HSM1.EGD.CMS.ECMS1.C00008_00041_M00038","vt":"str"},{"t":"cont","v":"HSM1.EGD.CMS.ECMS1.C00008_00041_M00039","vt":"str"},{"t":"cont","v":"HSM1.EGD.CAX.ECAX1.C00001_00013_M00046","vt":"str"},{"t":"cont","v":"HSM1.EGD.CAX.ECAX1.C00001_00013_M00047","vt":"str"},{"t":"cont","v":"HSM1.EGD.CAX.ECAX1.C00001_00013_M00048","vt":"str"},{"t":"cont","v":"HSM1.EGD.CAX.ECAX1.C00001_00013_M00049","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":803.0142059326172,"y":348.00567626953125,"wires":[["1bba10da.c972cf"],["1bba10da.c972cf"],["1bba10da.c972cf"],["1bba10da.c972cf"],["1bba10da.c972cf"],["1bba10da.c972cf"],["1bba10da.c972cf"],["1bba10da.c972cf"]]},{"id":"826c0b5.3d86bf8","type":"trigger","z":"4ef988a0.0b4b48","op1":"lime","op2":"#2f2f2f","op1type":"str","op2type":"str","duration":"400","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":1843.571418762207,"y":213.71428203582764,"wires":[["21912bce.6f5414","22ca40b6.4a202"]]},{"id":"1bba10da.c972cf","type":"BooleanLogic","z":"4ef988a0.0b4b48","name":"","operation":"OR","inputCount":"7","topic":"result","x":1240.071418762207,"y":316.71428203582764,"wires":[["b3abc930.9350f8","341eb311.e0cecc"]]},{"id":"b3abc930.9350f8","type":"switch","z":"4ef988a0.0b4b48","name":"No Bar On Mill","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1397.571418762207,"y":214.71428203582764,"wires":[["74f2f3ef.629ffc"]]},{"id":"74f2f3ef.629ffc","type":"delay","z":"4ef988a0.0b4b48","name":"","pauseType":"delay","timeout":"800","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1616.071418762207,"y":214.71428203582764,"wires":[["826c0b5.3d86bf8"]]},{"id":"21912bce.6f5414","type":"ui_template","z":"4ef988a0.0b4b48","group":"c2c79193.73a54","name":"","order":1,"width":0,"height":0,"format":"<svg version=\"1.1\" baseProfile=\"full\"\nxmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\nwidth=\"650x\" height=\"800px\" viewBox=\"0 0 300 300\">\n\t<defs>\n\t\t<g id=\"fig\" fill=\"{{msg.payload}}\">\n\t\t\t<circle cx=\"82\" cy=\"27\" r=\"25\" />\n\t\t\t<path style = \"fill: {{msg.payload}};\" d=\"M 157,162 C 92,60 98,58 74,57 C 60,57 59,61 35,80 C 6,102 8,102 8,126 C 8,154 6,152 29,163 L 29,115 L 49,97 L 49,165 L 97,164 L 98,110 C 137,171 134,168 157,162 z M 96,171 L 50,171 C 50,182 46,181 21,228 C -5,276 -5,273 10,300 L 74,184 C 136,302 128,299 162,297 L 128,233 C 99,181 97,181 96,171 z \" />\n\t\t</g>\n\t</defs>\n\t<use xlink:href=\"#fig\" opacity=\"0.1\" />\n\t<use xlink:href=\"#fig\" opacity=\"0.2\" x=\"30\" />\n\t<use xlink:href=\"#fig\" opacity=\"0.3\" x=\"60\" />\n\t<use xlink:href=\"#fig\" opacity=\"0.5\" x=\"90\" />\n\t<use xlink:href=\"#fig\" opacity=\"1\" x=\"120\" />\n</svg>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":2211.071418762207,"y":250.71428203582764,"wires":[[]]},{"id":"120c0a8f.cde415","type":"ui_template","z":"4ef988a0.0b4b48","group":"853b724d.b93c4","name":"","order":1,"width":0,"height":0,"format":"<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" width=\"800px\" height=\"825px\" viewBox=\"0 0 512 512\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" enable-background=\"new 0 0 512 512\">\n  <path style= \"fill: {{msg.payload}};\" d=\"m502.625,121.375l-112-112c-6-6-14.141-9.375-22.625-9.375h-224c-8.484,0-16.625,3.375-22.625,9.375l-112,112c-6,6-9.375,14.141-9.375,22.625v224c0,8.484 3.375,16.625 9.375,22.625l112,112c6,6 14.141,9.375 22.625,9.375h224c8.484,0 16.625-3.375 22.625-9.375l112-112c6-6 9.375-14.141 9.375-22.625v-224c0-8.484-3.375-16.625-9.375-22.625zm-134.625,118.621v112c0,35.348-34.262,64.004-69.609,64.004h-46.555c-30.305,0-58.004-17.121-71.555-44.225l-9.891-19.778-40.824-95.258c-4.027-9.402-0.031-20.313 9.113-24.887 8.91-4.453 22.547-1.406 27.824,7.039l25.497,36.304v-35.199-128c0-8.836 7.164-16 16-16s16,7.164 16,16v120c0,4.418 3.582,8 8,8s8-3.582 8-8v-152c0-8.836 7.164-16 16-16s16,7.164 16,16v152c0,4.418 3.582,8 8,8s8-3.582 8-8v-120c0-8.836 7.164-16 16-16s16,7.164 16,16v128 8c0,4.418 3.582,8 8,8s8-3.582 8-8v-8-80c0-8.836 7.164-16 16-16s16,7.164 16,16v80z\"/>\n</svg>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":2214.071418762207,"y":374.71428203582764,"wires":[[]]},{"id":"ae98913a.5cbad","type":"trigger","z":"4ef988a0.0b4b48","op1":"red","op2":"#2f2f2f","op1type":"str","op2type":"str","duration":"400","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":1924.571418762207,"y":347.71428203582764,"wires":[["120c0a8f.cde415","5ad1320f.1e047c"]]},{"id":"341eb311.e0cecc","type":"switch","z":"4ef988a0.0b4b48","name":"No Bar On Mill","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1478.571418762207,"y":348.71428203582764,"wires":[["75b3f3c.b34570c"]]},{"id":"75b3f3c.b34570c","type":"delay","z":"4ef988a0.0b4b48","name":"","pauseType":"delay","timeout":"800","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1697.071418762207,"y":348.71428203582764,"wires":[["ae98913a.5cbad"]]},{"id":"7f273699.461ee8","type":"ui_media","z":"4ef988a0.0b4b48","group":"a870758a.470318","name":"","width":"13","height":"15","order":4,"category":"images","file":"erdemir_logo.png","layout":"center","showcontrols":true,"loop":true,"onstart":false,"scope":"local","tooltip":"","x":2212.571418762207,"y":525.7142820358276,"wires":[[]]},{"id":"22ca40b6.4a202","type":"change","z":"4ef988a0.0b4b48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"images/walk.png","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1846.571418762207,"y":488.71428203582764,"wires":[["7f273699.461ee8"]]},{"id":"5ad1320f.1e047c","type":"change","z":"4ef988a0.0b4b48","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"images/stop.png","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1866.571418762207,"y":568.7142820358276,"wires":[["7f273699.461ee8"]]},{"id":"3f8ca931.42a326","type":"ui_media","z":"4ef988a0.0b4b48","group":"40aab9d6.640138","name":"","width":"20","height":"15","order":4,"category":"videos","file":"5x5 bilgilendirme sunusu.mp4","layout":"expand","showcontrols":true,"loop":true,"onstart":false,"scope":"local","tooltip":"","x":2218.571418762207,"y":650.7142820358276,"wires":[[]]},{"id":"9e7d0c98.65ee7","type":"function","z":"4ef988a0.0b4b48","name":"","func":"for(var i in msg.payload.values)\n{\n    var newmessage = msg.payload.values[i].v;\n        var newtopic = msg.topic + '/' + msg.payload.values[i].id;\n    node.send({ payload:newmessage, topic:newtopic });\n}","outputs":1,"noerr":0,"x":624.2857131958008,"y":345.71428871154785,"wires":[["8c301cf7.9daa1","a28ade01.551f1"]]},{"id":"a28ade01.551f1","type":"debug","z":"4ef988a0.0b4b48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":552.8571428571428,"y":557.1428571428571,"wires":[]},{"id":"3f3ac09c.ddccf","type":"json","z":"4ef988a0.0b4b48","name":"","property":"payload","action":"obj","pretty":false,"x":453.0142059326172,"y":348.00567626953125,"wires":[["9e7d0c98.65ee7"]]},{"id":"7ea52760.c63ad8","type":"mqtt-broker","z":"","name":"","broker":"10.67.20.56","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"c2c79193.73a54","type":"ui_group","z":"","name":"GEÇ","tab":"ca9cc3c1.f8817","disp":true,"width":"16","collapse":false},{"id":"853b724d.b93c4","type":"ui_group","z":"","name":"DUR","tab":"ca9cc3c1.f8817","order":2,"disp":true,"width":"16","collapse":false},{"id":"a870758a.470318","type":"ui_group","z":"","name":"Kontrol","tab":"f16092f1.6205d","order":1,"disp":true,"width":"13","collapse":false},{"id":"40aab9d6.640138","type":"ui_group","z":"","name":"Görsel","tab":"f16092f1.6205d","order":2,"disp":true,"width":"20","collapse":false},{"id":"ca9cc3c1.f8817","type":"ui_tab","z":"","name":"Yaya Kontrol Sistemi","icon":"dashboard","disabled":false,"hidden":false},{"id":"f16092f1.6205d","type":"ui_tab","z":"","name":"Yaya Kontrol Sistemi v0.1","icon":"dashboard","disabled":false,"hidden":false}]

I took your function ( without the return msg line) and put your data through it.
It works

[{"id":"4370e601.bf2848","type":"function","z":"58e8a98c.f592e8","name":"","func":"for(var i in msg.payload.values)\n{\nvar newmessage = msg.payload.values[i].v;\nvar newtopic = msg.topic + '/' + msg.payload.values[i].id;\nnode.send({ payload:newmessage, topic:newtopic });\n}\n\n","outputs":1,"noerr":0,"x":401.5,"y":239,"wires":[["29dea13d.35fe26"]]},{"id":"23bf86e7.98d68a","type":"function","z":"58e8a98c.f592e8","name":"","func":"msg.payload={};\nmsg.payload.values=[{\"id\":\"HSM1.EGD.CAX.ECAX1.C00001_00013_M00049\",\"v\":false,\"q\":true,\"t\":1569486884539}]\nreturn msg;","outputs":1,"noerr":0,"x":282.5,"y":92,"wires":[["4370e601.bf2848"]]},{"id":"29dea13d.35fe26","type":"debug","z":"58e8a98c.f592e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":568.5,"y":195,"wires":[]},{"id":"44c3991e.9cfcd8","type":"inject","z":"58e8a98c.f592e8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":114.5,"y":86,"wires":[["23bf86e7.98d68a"]]}]

Any fault lies elsewhere in your flow. I suggest you put debug nodes along your flow and see if the messages being sent along teh flow are what you think they are

You are right.

I was found problem at MQTT Broker side. I have adjusted the publish options to the Only on Data Changes. Then i select /Every Scan/. Problem solved.

Best regards

1 Like