I know I have "been down this path before" but I have since learned more and am stuck at another part of the journey.
I have found this ability to make "lists" on the screen.
It is a ui_template
node and the code is:
<table id="table" border="1">
<tr>
<th>Front door events</th>
</tr>
<tbody>
<tr ng-repeat="row in msg.payload track by $index">
<td class="text" >{{row}}</td>
</tr>
</tbody>
</table>
I was stuck with this in another way recently but that isn't applicable to the latest task I have.
At random times things will happen.
I want to create a list of them - say 10 lines big - and show the last 10 events.
As they come in, they are formatted and sent to this node and displayed.
Alas as is, this has no memory and so every new event is shown and the previous one wiped.
What I am needing is an array that keeps the last 10 events and when a new one comes in, it shuffles them down one place and sticks the latest one on the queue and re-sends the entire list. I'm guessing.
That would require a function
node I also guess.
There aren't any nodes that do this already are there?
I can't seem to resolve any from my search, but it somewhat depends on how the node is described by the person writing it and what I make of it.
Thanks.
This is what I have bashed up (with work in progress)
var new_msg = msg.payload[0];
//node.warn("Incoming message is " + new_msg);
var topic = "Main door events";
// Set up stack for old messages.
var message1 = context.get("message1");
var message2 = context.get("message2");
var message3 = context.get("message3");
var message4 = context.get("message4");
var message5 = context.get("message5");
var message6 = context.get("message6");
var message7 = context.get("message7");
var message8 = context.get("message8");
var message9 = context.get("message9");
if (msg.wipe === 1)
{
//
// Wipe all messages.
// (work needed)
}
message9 = message8;
message8 = message7;
message7 = message6;
message6 = message5;
message5 = message4;
message4 = message3;
message3 = message2;
message2 = message1;
message1 = new_msg;
context.set("message1",message1);
context.set("message2",message2);
context.set("message3",message3);
context.set("message4",message4);
context.set("message5",message5);
context.set("message6",message6);
context.set("message7",message7);
context.set("message8",message8);
context.set("message9",message9);
//node.warn(message1);
//node.warn(message2);
//node.warn(message3);
msg = {"topic":topic,"payload":[message1,message2,message3,message4,message5,message6,message7,message8,message9]};
return msg;
I think you will find this node very handy for the purpose: node-red-contrib-ring-buffer
1 Like
I have made more progress on the function
node getting it working.
But I will look at it.
Thanks.