Skip to content

Instantly share code, notes, and snippets.

@hovissimo hovissimo/Magic Gate

Created Aug 11, 2014
Embed
What would you like to do?
Magic Gate function for Node-RED, it let's you repeat messages arbitrarily
/* This function node will store the last message it
received as long as msg.payload != "abracadabra".
If this function receives a msg where the payload
exactly equals "abracadabra" then the stored
message will be forwarded.
This function is designed for storing and replaying
messages to help in testing flows. You can use it
by wiring up between two nodes where you want to
control or repeat messages, and also adding an
INJECT input that sends a the magic word in the
payload.
---Hovis
*/
context.storedMessage = context.storedMessage || {};
if (msg.payload != "abracadabra") {
context.storedMessage = msg;
} else {
return context.storedMessage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.