Function with multiple output combined with node-red-contrib-boolean-logic

Hi, I try to use a function with multiple outputs and combine this logic with the “node-red-contrib-boolean-logic”. As long as I use only one output this combination works fine. As soon as I try to use multiple output the Boolean logic elements does not work as expected. Based on the debug messages I get the expected Boolean outputs. Any idea what is wrong in my logic?

My flow extract:

[{"id":"4bef83eb.56ac0c","type":"debug","z":"58a87a42.fba714","name":"Out1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":1560,"wires":[]},{"id":"59d8d229.4263f4","type":"BDebug","z":"58a87a42.fba714","name":"Debug","x":630,"y":1800,"wires":[]},{"id":"b2052a1c.bfd828","type":"BDebug","z":"58a87a42.fba714","name":"Debug","x":630,"y":1500,"wires":[]},{"id":"c88524d0.06f258","type":"function","z":"58a87a42.fba714","name":"Hysteresis","func":"var testTrue = {payload:true};\nvar testFalse = {payload:false};\n\n\nreturn [testTrue, testFalse];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":390,"y":1640,"wires":[["b2052a1c.bfd828","4bef83eb.56ac0c","b2a4ea6a.086778"],["59d8d229.4263f4","1e4aef66.577d89","b2a4ea6a.086778"]]},{"id":"1e4aef66.577d89","type":"debug","z":"58a87a42.fba714","name":"Out2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":1740,"wires":[]},{"id":"b2a4ea6a.086778","type":"BooleanLogic","z":"58a87a42.fba714","name":"","operation":"OR","inputCount":"2","topic":"result","x":630,"y":1640,"wires":[[]]},{"id":"d38d5c2a.566a08","type":"inject","z":"58a87a42.fba714","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":1640,"wires":[["c88524d0.06f258"]]}]

As described in the help text the boolean node uses message topics to identify the values to be ORd together. You need to specify different topics for the messages coming in on the two paths. So if, in your function you put

var testTrue = {topic: "A", payload:true};
var testFalse = {topic: "B", payload:false};
return [testTrue, testFalse];

then it should work.

1 Like

@Coline: That’s it, it works know perfect.
Thank you for your fast response!

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