Display output message from several inputs

#1

Hi everyone. I need to get the output message from several inputs (3 or 4 inputs). For example, I got two different mental commands which are shown in the picture below. I need to display the message based on which mental commands I'm receiving. When the 'left' command is received and the sensitivity is over 30, the message 'left' will be displayed. If the sensitivity is less than 30, then the 'no signal' message will be displayed. It works fine with only one mental command in the flow. When I add the second mental command in the flow and want to compare the signals from the two commands, the output can only display the message from the second command.


How can I do the comparison and choose the right one from different commands? Can I use the join node to do it? I've tried the join node but the debug message shows the error messages like below.

Any helps will be appreciated. Thank you.

0 Likes

#2

Use the join node in manual mode and select key/value pairs.

0 Likes

#3

Hi @Sin

Take a look at this recipe in the cookbook: https://cookbook.nodered.org/basic/join-streams

It describes how to combine separate streams of messages into one using the Join node. They key thing it to configure the Join node in manual mode with the options for how you want it to join the messages.

The 'automatic' join mode only works if the messages it receives are already part of a valid message sequence - for example from the output of the Split node.

1 Like

#4

Is this means that I need to set the 'count' for the join node? What does the 'count' mean?

How can I join the messages? I just want to compare the values of the commands and display the highest one.

0 Likes

#5

If you follow the example I linked to, you can get a single message with the latest value from both branches of your flow in. You can then use a Function node to compare those two values and make whatever decision you want.

For that to work - as described in the recipe, you'll need each message to have its own msg.topic property to identify which branch it is from - you can add a Change node after each Mental Commands node to set it.

You then need to configure the Join node as the recipe describes.

Once you have done that, feed the output to a Debug node so you can see the result.

0 Likes

#6

Is this is what you means?
image
image

0 Likes

#7

You've got the right idea for the Change node, but your Join node is not correct.

Please read the recipe I linked to at the start. It describes how the Join node should be configured. You can also import the flow it provides and have a look at its Join node.

1 Like

#8

Okay. I'll try it tomorrow.

0 Likes