How to compare 2 values

Hello,
can someone please help me.

i would like to compare 2 values.

Unfortunately I am too stupid and cannot manage it.

[{"id":"c74b60cf.0feba8","type":"ui_led","z":"f4339f33.43893","group":"2c48b410.e40854","order":5,"width":"0","height":"0","label":"ok","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"1","valueType":"num"}],"allowColorForValueInMessage":false,"name":"ok","x":990,"y":180,"wires":[]},{"id":"d83a99d1.871aa","type":"function","z":"f4339f33.43893","name":"","func":"var nombre1 = msg.payload;\n\nmsg.payload = {\n    \"content1\":nombre1\n    \n};\n\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":200,"wires":[["ca8de8dd.6ab55","cc03b8f1.3849f8"]]},{"id":"9a9a991c.8053f","type":"function","z":"f4339f33.43893","name":"","func":"var nombre2 = msg.payload;\n\nmsg.payload = {\n    \"content2\":nombre2\n    \n};\n\n\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":260,"wires":[["4d47840.39f6b7c","cc03b8f1.3849f8"]]},{"id":"ca8de8dd.6ab55","type":"debug","z":"f4339f33.43893","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":140,"wires":[]},{"id":"4d47840.39f6b7c","type":"debug","z":"f4339f33.43893","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":200,"wires":[]},{"id":"cc03b8f1.3849f8","type":"join","z":"f4339f33.43893","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":320,"wires":[["b697b990.cc4b58","a911eacd.0470f"]]},{"id":"a911eacd.0470f","type":"function","z":"f4339f33.43893","name":"vergleiche","func":"var content1 = msg.payload.content1;\nvar content2 = msg.payload.content2;\n\nif (content1 >= content2)\n{\nmsg.payload = 1;\n}\nelse\n{\nmsg.payload = 0;\n}\nreturn msg","outputs":1,"noerr":0,"x":750,"y":320,"wires":[["c74b60cf.0feba8","35ce701f.fcc9b8"]]},{"id":"35ce701f.fcc9b8","type":"debug","z":"f4339f33.43893","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1050,"y":460,"wires":[]},{"id":"b697b990.cc4b58","type":"debug","z":"f4339f33.43893","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":460,"wires":[]},{"id":"7029c129.f22808","type":"ui_text_input","z":"f4339f33.43893","name":"","label":"","tooltip":"","group":"2c48b410.e40854","order":9,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":140,"y":200,"wires":[["d83a99d1.871aa"]]},{"id":"a423cde4.b64da8","type":"ui_text_input","z":"f4339f33.43893","name":"","label":"","tooltip":"","group":"2c48b410.e40854","order":10,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":160,"y":260,"wires":[["9a9a991c.8053f"]]},{"id":"2c48b410.e40854","type":"ui_group","z":"","name":"Timer 1","tab":"170691f8.d5f3ae","order":1,"disp":true,"width":"6","collapse":false},{"id":"170691f8.d5f3ae","type":"ui_tab","z":"","name":"Zeitschaltuhr","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

thx

When using the join node you need to specify the parts. One way is to use a change node. Also adding in some inject nodes will save you from having to go back and forth to the dashboard. try this flow:

[{"id":"6a381c77.a7a254","type":"tab","label":"Flow 9","disabled":false,"info":""},{"id":"8ef78bd8.b819","type":"ui_led","z":"6a381c77.a7a254","group":"7f77248a.7eca24","order":5,"width":"0","height":"0","label":"ok","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"1","valueType":"num"}],"allowColorForValueInMessage":false,"name":"ok","x":770,"y":240,"wires":[]},{"id":"6e60cf4c.885068","type":"debug","z":"6a381c77.a7a254","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":220,"wires":[]},{"id":"9c33d1ed.f3228","type":"debug","z":"6a381c77.a7a254","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":420,"wires":[]},{"id":"e77acd15.126808","type":"join","z":"6a381c77.a7a254","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"key","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":470,"y":320,"wires":[["e6ac2cdb.d11e3","e562bcd2.a16378"]]},{"id":"e562bcd2.a16378","type":"function","z":"6a381c77.a7a254","name":"vergleiche","func":"var content1 = msg.payload.content1;\nvar content2 = msg.payload.content2;\n\nif (content1 >= content2)\n{\nmsg.payload = 1;\n}\nelse\n{\nmsg.payload = 0;\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":320,"wires":[["8ef78bd8.b819","2d5da03d.167368"]]},{"id":"2d5da03d.167368","type":"debug","z":"6a381c77.a7a254","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":770,"y":380,"wires":[]},{"id":"e6ac2cdb.d11e3","type":"debug","z":"6a381c77.a7a254","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":420,"wires":[]},{"id":"8a3121f9.11e55","type":"ui_text_input","z":"6a381c77.a7a254","name":"","label":"","tooltip":"","group":"7f77248a.7eca24","order":9,"width":0,"height":0,"passthru":true,"mode":"text","delay":"3000","topic":"content1","x":100,"y":280,"wires":[["f5a73010.31ce4"]]},{"id":"a3fe0ac7.c0ec48","type":"ui_text_input","z":"6a381c77.a7a254","name":"","label":"","tooltip":"","group":"7f77248a.7eca24","order":10,"width":0,"height":0,"passthru":true,"mode":"text","delay":"3000","topic":"","x":100,"y":340,"wires":[["47b3f4c5.54a4ac"]]},{"id":"f5a73010.31ce4","type":"change","z":"6a381c77.a7a254","name":"","rules":[{"t":"set","p":"id","pt":"msg","to":"content1","tot":"str"},{"t":"set","p":"index","pt":"msg","to":"textin","tot":"str"},{"t":"set","p":"count","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"type","pt":"msg","to":"string","tot":"str"},{"t":"set","p":"key","pt":"msg","to":"content1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":280,"wires":[["e77acd15.126808","6e60cf4c.885068"]]},{"id":"47b3f4c5.54a4ac","type":"change","z":"6a381c77.a7a254","name":"","rules":[{"t":"set","p":"id","pt":"msg","to":"content1","tot":"str"},{"t":"set","p":"index","pt":"msg","to":"textin","tot":"str"},{"t":"set","p":"count","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"type","pt":"msg","to":"string","tot":"str"},{"t":"set","p":"key","pt":"msg","to":"content2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":340,"wires":[["e77acd15.126808","9c33d1ed.f3228"]]},{"id":"21803b99.ee6b84","type":"inject","z":"6a381c77.a7a254","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19","payloadType":"num","x":120,"y":220,"wires":[["f5a73010.31ce4"]]},{"id":"5577b663.c1e628","type":"inject","z":"6a381c77.a7a254","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":100,"y":400,"wires":[["47b3f4c5.54a4ac"]]},{"id":"7b5372eb.4e94bc","type":"inject","z":"6a381c77.a7a254","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":110,"y":160,"wires":[["f5a73010.31ce4"]]},{"id":"f9391a97.45508","type":"inject","z":"6a381c77.a7a254","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19","payloadType":"num","x":90,"y":460,"wires":[["47b3f4c5.54a4ac"]]},{"id":"7f77248a.7eca24","type":"ui_group","z":"","name":"Timer 1","tab":"c884960e.f9c938","order":1,"disp":true,"width":"6","collapse":false},{"id":"c884960e.f9c938","type":"ui_tab","z":"","name":"Zeitschaltuhr","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

Watch this and in about 4 minutes it should be a lot clearer.

Use topic instead of the first functions.

[{"id":"81f22761.52fb08","type":"debug","z":"1c506f8.684a991","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":479,"y":471,"wires":[]}]

@harelabb
when i copy your code i become only 1 msg.payload.

I think that has lost something in the translation, can you say again what you mean?

sorry for my bad english.
I use google to translate.

I only want to compare 2 values.

one comes from a controller as a number,
the other from the dashboard.

I have solved it so now

[{"id":"b4ea084f.1fcca","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"a0383e4e.4c7338","type":"function","z":"b4ea084f.1fcca","name":"","func":"var test = msg.payload;\n\nreturn{ topic: 'b', payload: test};","outputs":1,"noerr":0,"x":270,"y":120,"wires":[["1531620.c58311e"]]},{"id":"66a6580c.0cb44","type":"debug","z":"b4ea084f.1fcca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":220,"wires":[]},{"id":"8f96164b.13dd08","type":"ui_led","z":"b4ea084f.1fcca","group":"2c48b410.e40854","order":5,"width":"0","height":"0","label":"ok","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"green","value":"1","valueType":"str"}],"allowColorForValueInMessage":false,"name":"ok","x":710,"y":100,"wires":[]},{"id":"1531620.c58311e","type":"function","z":"b4ea084f.1fcca","name":"vergleiche","func":"context.node = context.node || 0;\ncontext.node1 = context.node1 || 0;\n\nif(msg.topic == 'a'){\n    context.node = msg.payload;\n} else if (msg.topic == 'b'){\n    context.node1 = msg.payload;\n}\n\nif (context.node == context.node1){\n    return{ topic: 'd', payload: '1'}\n}else{\n    return{ topic: 'e', payload: '0'}\n}","outputs":1,"noerr":0,"x":490,"y":160,"wires":[["8f96164b.13dd08","66a6580c.0cb44"]]},{"id":"47262662.4bfc68","type":"function","z":"b4ea084f.1fcca","name":"","func":"var test1 = msg.payload;\n\nreturn{ topic: 'a', payload: test1};","outputs":1,"noerr":0,"x":270,"y":200,"wires":[["1531620.c58311e"]]},{"id":"d1f30c47.31754","type":"inject","z":"b4ea084f.1fcca","name":"","topic":"","payload":"12","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":80,"wires":[["a0383e4e.4c7338"]]},{"id":"26d0e224.d25d6e","type":"inject","z":"b4ea084f.1fcca","name":"","topic":"","payload":"12","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":200,"wires":[["47262662.4bfc68"]]},{"id":"e0fcafc3.4ec518","type":"inject","z":"b4ea084f.1fcca","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":120,"wires":[["a0383e4e.4c7338"]]},{"id":"15b797fc.4ee49","type":"inject","z":"b4ea084f.1fcca","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":240,"wires":[["47262662.4bfc68"]]},{"id":"2c48b410.e40854","type":"ui_group","z":"","name":"Timer 1","tab":"170691f8.d5f3ae","order":1,"disp":true,"width":"6","collapse":false},{"id":"170691f8.d5f3ae","type":"ui_tab","z":"","name":"Zeitschaltuhr","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

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