Need help with how to do this

um no?

if the "random" sent 1,2,3 then you want to ignore these & IF the other message comes, you want a message with 1,2,3 in it? or just 3? or?

Ok....

I am sending messages with the time (stamp) as the payload.

So the payload is/should be something like:
18:21:00@6,1

That message structure is sent out every second.
Sent via MQTT to a python script.

I was/am getting weird things on the screen.
I was asking and someone asked for the code.

I posted the python code and they found a problem with the code's structure.
If the message's format was/is wrong (no @x,y) at the end, it would just print at the next position on the screen.

I modified the code and now if that condition exists, it sends the message back on another MQTT topic.

I get that in NR and want to compare that to the message I just sent to the python script.

So it only needs to send me the last message as I want to see that and compare it to the one I just got sent back from the python script.

Another way to explain it:
I send the script A and it gets B - for some reason.
Rather than print B on the screen, I send B back to NR.
NR then gets B and finds A - which was just sent - and shows me the two together so I can see if they are (or not) the same.

Better?

It is NOT capturing the whole sequence. Only holding the last one and sending it if it gets told there is a difference.

Then the demo flow you posted does just that.

HOWEVER if node-red is actually sending "rubbish" you will possibly end up in a loop.

e.g...

NR Sends Python sees Python does
18:21:00@6,1 18:21:00@6,1 prints it
18:21:01@6,1 18:21:01@6,1 prints it
rubbish rubbish sends it back
rubbish rubbish sends it back
rubbish rubbish sends it back
rubbish rubbish sends it back
rubbish rubbish sends it back
rubbish rubbish sends it back
rubbish rubbish sends it back

etc etc etc

No, this code is at a dead end and logging only.

The code does not send the message back into the system.

The python script sends the corrupt (non-compliant message) back on another topic/channel.

So when NR detects that message, the topic is set to something and sent into the function node which then releases it's stored version of that message and puts the two together and shows me in a debug node.

That way I can see if/where the difference is.

Alas it isn't really helping me. Though it has reduced the number of erroneous / extraneous things on the screen.

Alas they are still happening and I don't know why.

But until this is working correctly, I can't be sure.

I originally asked because I was stuck on how to cache the sent message and only release it if another special type of message was received.
The special part was achieved by setting the topic to something.

But how to hold it and.... anyway.

You already figured that out with your demo flow and random numbers.

What part are you stuck with?

It was (note: WAS) how to get the node to hold (cache) the original message and only release it if a special message (with the topic set) is received.

If no message is received: just go to the next one.
So the 1, 4, n (random) inputs are just examples.

Sorry... It is now working. Again I shall explain: If I didn't ask (while trying to get it working) I would not have got it working and would have to have asked.

I also got a bit stuck with the null undefined and "" comparison. But that's another story.

Thanks to all who replied and helped.

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