Split and Join Objects

Hello, I am trying to inject two JSON Object messages with an rbe to block repeated message. The rbe blocks only single ID's so I split them, then joined them with the parts.key and then passed them through rbe. But it's not working as expected. I added the flow below.
Also for some reason the join node second inject will show 6 messages instead of 1, what is the logic behind that? Thank you!

[{"id":"1fc07194.1c283e","type":"tab","label":"Merge Test","disabled":false,"info":""},{"id":"f7be99f8.23e6e8","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":390,"y":260,"wires":[["70605503.9689ac"]]},{"id":"70605503.9689ac","type":"split","z":"1fc07194.1c283e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":260,"wires":[["a2a618d1.d56af8"]]},{"id":"ba7a207b.8ee4c","type":"debug","z":"1fc07194.1c283e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1150,"y":360,"wires":[]},{"id":"a2a618d1.d56af8","type":"function","z":"1fc07194.1c283e","name":"","func":"var ID = msg.parts.key\nvar value = msg.payload\nmsg.payload = { [ID] : value }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":260,"wires":[["390d1a99.cb60a6"]]},{"id":"8f086b30.19b718","type":"join","z":"1fc07194.1c283e","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":360,"wires":[["ba7a207b.8ee4c"]]},{"id":"fa877dae.57a9c","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":2,\"b\":3,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":390,"y":340,"wires":[["70605503.9689ac"]]},{"id":"390d1a99.cb60a6","type":"rbe","z":"1fc07194.1c283e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","x":870,"y":260,"wires":[["8f086b30.19b718","b40074ef.60e3a8"]]},{"id":"b40074ef.60e3a8","type":"debug","z":"1fc07194.1c283e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1090,"y":240,"wires":[]}]```

The rbe would also need a topic, as the messages without a topic are counted as one topic, so all different payloads would pass. I added a time out for the join.
heres an example

[{"id":"33e2b927.286dce","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":390,"y":540,"wires":[["dad804ad.187958"]]},{"id":"dad804ad.187958","type":"split","z":"1fc07194.1c283e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":550,"y":540,"wires":[["d7fb3d8b.bc89b8"]]},{"id":"d7fb3d8b.bc89b8","type":"function","z":"1fc07194.1c283e","name":"","func":"var ID = msg.parts.key\nvar value = msg.payload\nmsg.payload = { [ID] : value }\nmsg.topic= ID;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":700,"y":540,"wires":[["aad556df.3dcd4"]]},{"id":"580fa230.24a8d4","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":2,\"b\":3,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":390,"y":620,"wires":[["dad804ad.187958"]]},{"id":"aad556df.3dcd4","type":"rbe","z":"1fc07194.1c283e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":870,"y":540,"wires":[["2d22108f.f54b98"]]},{"id":"2d22108f.f54b98","type":"join","z":"1fc07194.1c283e","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":810,"y":620,"wires":[["7e3e3d3c.d73e1c"]]},{"id":"c9e876fc.05279","type":"inject","z":"1fc07194.1c283e","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":750,"y":480,"wires":[["aad556df.3dcd4"]]},{"id":"7e3e3d3c.d73e1c","type":"debug","z":"1fc07194.1c283e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":620,"wires":[]},{"id":"65f00ceb.9555b4","type":"inject","z":"1fc07194.1c283e","name":"complete","props":[{"p":"complete","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":670,"y":680,"wires":[["2d22108f.f54b98"]]}]

[edit] or you could add a trigger node to time out quicker.

[{"id":"33e2b927.286dce","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":290,"y":540,"wires":[["697432dd.ae5ba4"]]},{"id":"697432dd.ae5ba4","type":"split","z":"1fc07194.1c283e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":430,"y":540,"wires":[["436c0986.6891a"]]},{"id":"436c0986.6891a","type":"function","z":"1fc07194.1c283e","name":"format payload","func":"let ID = msg.parts.key;\nlet value = msg.payload;\nmsg.payload = { [ID] : value };\nmsg.topic = ID;\ndelete msg.parts;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":540,"wires":[["aad556df.3dcd4"]]},{"id":"580fa230.24a8d4","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":2,\"b\":3,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":290,"y":580,"wires":[["697432dd.ae5ba4"]]},{"id":"aad556df.3dcd4","type":"rbe","z":"1fc07194.1c283e","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":790,"y":540,"wires":[["2f2053cc.0b8174","2d22108f.f54b98"]]},{"id":"c9e876fc.05279","type":"inject","z":"1fc07194.1c283e","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":750,"y":480,"wires":[["aad556df.3dcd4"]]},{"id":"2f2053cc.0b8174","type":"trigger","z":"1fc07194.1c283e","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":970,"y":540,"wires":[["4781d0d1.0693e"]]},{"id":"2d22108f.f54b98","type":"join","z":"1fc07194.1c283e","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":790,"y":600,"wires":[["7e3e3d3c.d73e1c"]]},{"id":"4781d0d1.0693e","type":"change","z":"1fc07194.1c283e","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":540,"wires":[["2d22108f.f54b98"]]},{"id":"7e3e3d3c.d73e1c","type":"debug","z":"1fc07194.1c283e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":970,"y":600,"wires":[]}]
1 Like

I simplified it for you, and corrected the join issue.

[{"id":"1fc07194.1c283e","type":"tab","label":"Merge Test","disabled":false,"info":""},{"id":"f7be99f8.23e6e8","type":"inject","z":"1fc07194.1c283e","name":"{\"a\":1,\"b\":2,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":290,"y":240,"wires":[["70605503.9689ac"]]},{"id":"70605503.9689ac","type":"split","z":"1fc07194.1c283e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":530,"y":260,"wires":[["a2a618d1.d56af8"]]},{"id":"a2a618d1.d56af8","type":"function","z":"1fc07194.1c283e","name":"format payload","func":"let ID = msg.parts.key;\nlet value = msg.payload;\nmsg.payload = { [ID] : value };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":260,"wires":[["8f086b30.19b718"]]},{"id":"8f086b30.19b718","type":"join","z":"1fc07194.1c283e","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":870,"y":260,"wires":[["0a8d99ea7e863579"]]},{"id":"fa877dae.57a9c","type":"inject","z":"1fc07194.1c283e","name":"{\"a\":2,\"b\":3,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":2,\"b\":3,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":290,"y":280,"wires":[["70605503.9689ac"]]},{"id":"91561f102a8544aa","type":"debug","z":"1fc07194.1c283e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1150,"y":260,"wires":[]},{"id":"0a8d99ea7e863579","type":"rbe","z":"1fc07194.1c283e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1010,"y":260,"wires":[["91561f102a8544aa"]]},{"id":"4cdf2e828944b5d2","type":"comment","z":"1fc07194.1c283e","name":"Two different objects","info":"","x":230,"y":200,"wires":[]}]
2 Likes

@HaroldPetersInskipp Here is your flow simplified to the max. I removed all un-needed nodes to get same output.
LOL

[{"id":"85120793.18262","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":454.33331298828125,"y":718.6666259765625,"wires":[["a2f86242.9c488"]]},{"id":"a2f86242.9c488","type":"debug","z":"1fc07194.1c283e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":650,"y":720,"wires":[]},{"id":"c62dc5fc.b4afd8","type":"inject","z":"1fc07194.1c283e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":2,\"b\":3,\"C\":432,\"D\":2,\"E\":56,\"FR\":2}","payloadType":"json","x":454.33331298828125,"y":758.6666259765625,"wires":[["a2f86242.9c488"]]}]
2 Likes

Thank you so much, the trigger also helps a lot, I expect a high data rate coming in

That helps, my blocks are less ugly now, thank you!

1 Like

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