I am trying to create a loop in a function node in Node-Red that basically acts like a countdown timer for me. Right now when I run this node I only get a single output from the node with msg.playload saying "Back in 15 minutes".
What I want is to get 15 outputs one after another that say "Back in 15 minutes", "Back in 14 minutes", ect. Once I can get that I will add in a delay so that the for loop waits for 1 minute each time it runs.
var totalMinutes = 15
for (var i = 0; i < 15; i++){
var minutesLeft = totalMinutes - [i];
msg.payload = {
"profile": {
"status_text": "Back in " + minutesLeft + " minutes",
"status_emoji": ":coffee:",
"status_expiration": 0
}
};
return [msg.payload];
}
return [msg];