Problem with join node

Hey,
somehow I dont understand the join node.
I would like to combine some payloads but allways receive this error:

"Message missing key property 'msg.topic' - cannot add to object"

I use some buttons wich sends numbers as payload and I also set topic for this:
image

I would like to combine some input until 4 inputs are made and then send an output from join node, but it wont work.

What am I missing, why the join node dont add inputs??

And what is the value of msg.test?

Try adding test as a string.

well changing msg to string seems to work, but I thoght Topic: msg.test ist the topic with value of payload, in my case 1, I was expecting this output: test:1

you have set the topic to come from msg - that should probably be set to string

1 Like

how have you set join node? key/val mode?

1 Like

In a button setting Topic to msg.test means set msg.topic in the output message to the value of msg.test from an input message. If you just want the topic on the output set to the string "test" then set Topic to String type, test

image

1 Like

Yes I have set it to string and it works now, as expected,
but I try to understand why is msg.test doesnt work as topic? What do my node do? set the topic "test" on the msg value, so on "1"? Does it means that the topic is going to be removed?

yes it was key/val mode, but I noticed yet that the string fits better my purpose.

if the msg contains a property called "test" the value of msg.test will be used. So if msg.test doesnt exist, then undefined is sent - i.e. no topic - resulting in ""Message missing key property 'msg.topic' - cannot add to object""

I suspect you are new to node-red, I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

1 Like

I work with node red for 2 weeks now, so ye pretty new and I still have troubles to understand the msg and topic functions and how this works together. I will watch the playlist, thank you!

Here is an example showing msg.test to set the topic. Though I can't actually think of a use case where this would be helpful.

[{"id":"233a4bbc.3b1b64","type":"debug","z":"37f5b818.697af8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":680,"wires":[]},{"id":"58a81137.6c262","type":"ui_button","z":"37f5b818.697af8","name":"","group":"a8e4a3.d31edb6","order":3,"width":0,"height":0,"passthru":true,"label":"button topic test","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"test","topicType":"msg","x":300,"y":680,"wires":[["233a4bbc.3b1b64"]]},{"id":"57e7e1be.269268","type":"inject","z":"37f5b818.697af8","name":"msg.test: topic1","props":[{"p":"test","v":"topic1","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":120,"y":720,"wires":[["58a81137.6c262"]]},{"id":"17a4e8fc.b7d357","type":"inject","z":"37f5b818.697af8","name":"msg.test: topic2","props":[{"p":"test","v":"topic2","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":120,"y":640,"wires":[["58a81137.6c262"]]},{"id":"a8e4a3.d31edb6","type":"ui_group","name":"Chart","tab":"8032fe72.980b98","order":3,"disp":false,"width":"12","collapse":false},{"id":"8032fe72.980b98","type":"ui_tab","name":"PnH","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

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