May be this is a stupid question or I have just knots in my brain, but as I am completely new to Node Red, please forgive me my stupidness:
I have data from my 3d-Printer via MQTT in Node Red and I have a chatbot from Telegram. Both work individually. But now I'd like to output the status of my printer to telegram only, when "/status" is received via telegram.
How do I buffer the data that comes via MQTT until the "/status" - command comes in? This is what I currently have:
Just connect the mqtt node to a change node, store the payload into a context variable.
When requesting the /status, get the context variable and display it.
Or, if you want to avoid the use of context data (which can make it more difficult to follow the flow) then use a Join node in key/value mode to join the mqtt value with the telegram data and then every time a new message comes in you will be able to take appropriate action.
@Steve-Mcl and bakman2 : perfect, that is what I was searching for... (not only for this task)
@Colin : you are right, context makes things more difficult to understand, but I don't get how your proposal with the join node will work:
When new MQTT data arrives and /status is not triggered, then the following function evaluates to do nothing.
Then /status arrives, the function starts to output the last MQTT data, because it is still in the message object.
Then new MQTT data arrives. What is the state of the /status - isn't it still active? and therefore the function node creates an output?
You can check the topic of the output message from the join node (which will be the topic of the message it has just received) and ignore the message unless the topic is that for the telegram message.