If 1 message ... if 2 messages

Hello :slight_smile:

I have a little problem and can´t find a solution. Hope you can give me a tip.

I need something like this:

Input: message a -> Output message a
Input: message b -> Output message b
Input: message a + message b (in a given time) -> Output message a
Input: message b + message a (in a given time) -> Output message a

And the last one is my problem. The other 3 thinks work with a delay node, but I have no idea, what i can use, do to get all four thinks done.

Please give me a little input. Also a keyword to search is welcome, because I cant explain google what I want to find! :wink:

How would you determine which is message a and message b? do you know the what the messages would be? can they be identified in any way?

Your 2nd and 4th option may conflict.

If 4th, Input: message b + message a (in a given time) -> Output message a

Do you still want to output message b due to the 2nd condition and then output message a as well? Or just message a?

Thanks for reply! :slight_smile:

@ E1cid - Identify the messages is no problem. There will be a part in the message witch exactly say it is message a or b.

@ HaroldPetersInskipp - You are right. It has to be: Input: message b (in a given time) -> Output message b

Would of been nice to see these messages.

Here is an example, may help

[{"id":"2cb79f6d.89d9e","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id\":\"a\",\"payload\":1}","payloadType":"json","x":150,"y":1500,"wires":[["aa5af8be.431c08"]]},{"id":"aa5af8be.431c08","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":320,"y":1500,"wires":[["b8726ad6.5804d8"]]},{"id":"b8726ad6.5804d8","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$count($$.payload)=1 ? $$.payload[0] : \"a\" in $$.payload.id ? $$.payload[id = \"a\"][0] : $$.payload[id =\"b\"][0]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1500,"wires":[["2c7ddea7.0f6dca"]]},{"id":"ecf1849d.e31508","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id\":\"b\",\"payload\":2}","payloadType":"json","x":130,"y":1540,"wires":[["aa5af8be.431c08"]]},{"id":"2c7ddea7.0f6dca","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":720,"y":1500,"wires":[]}]

the time between messages is set in the join timeout for less than a second use decimals e.g. 0.5

Or similar with objects joined.

[{"id":"2cb79f6d.89d9e","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id\":\"a\",\"payload\":1}","payloadType":"json","x":150,"y":1500,"wires":[["aa5af8be.431c08"]]},{"id":"aa5af8be.431c08","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"payload.id","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":320,"y":1500,"wires":[["b8726ad6.5804d8"]]},{"id":"ecf1849d.e31508","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id\":\"b\",\"payload\":2}","payloadType":"json","x":150,"y":1540,"wires":[["aa5af8be.431c08"]]},{"id":"b8726ad6.5804d8","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$count($$.payload.*) = 1 ?  $$.payload.* : $$.payload.*[id = \"a\"]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1500,"wires":[["2c7ddea7.0f6dca"]]},{"id":"2c7ddea7.0f6dca","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":1500,"wires":[]}]
1 Like

Thanks a lot! Not only a tip, a whole example ... perfect!
Now I have something I can work with. :slight_smile:
Will have a look if it works for me :wink:

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