I have multiple node (e.g. date + server status message (via http get)) and I want to display a list of the last x messages on the node-red dashboard. I could not find a node / npm package for this, I assume I can do it with the standard packages?
List example:
The message handling ain't the problem here, but how to output and delete the xth entry in the list if a new one comes in?
Sounds like you need to look at how use the context to store data.
The simplest way to do this will be in a function node, something like this:
var list = context.get("statusList") || [];
var date = new Date().toLocaleDateString();
var entry = date + " - " + msg.payload;
list.push(entry);
if (list.length > 5) {
list = list.slice(-5);
}
context.put("statusList", list);
msg.payload = list;
return msg;
This should keep the last 5 input messages and outputs and array with those 5 messages.