Buffer list_ui input?

Hello Guys,

after many nights my rfid reader dashboard looks the way i want to and works great.

The last thing i want to have is a logger that shows me the last users who access the reader.

I want to do this with the "ui-list" https://flows.nodered.org/node/node-red-node-ui-list

after a bit of testing, i do a inject node for example, formatted with a json code, to show me in the list what i wanted.

I build a second example inject node, but this replaced the first information, but i want a "growing list".... i was aware off....

Till i find the node "ring-buffer" https://flows.nodered.org/node/node-red-contrib-ring-buffer.

I was very happy, that is exactly the node iam looking for, i can set the maximal capacity of messages and sort them from old to new and so on.

if you put a meesage in it stacks the messages, till the size is reached.

my problem is now, how to format the output of the ring buffer correct to display the "growing list" in my ui-list node.

i hope someone can help me.

This works like i want, but replaces the message before:

[{"id":"415371c4.bf4fd","type":"ui_list","z":"c7a9e01b.3778c","group":"bb9f2da2.5fec9","name":"","order":1,"width":"12","height":"5","lineType":"two","actionType":"none","allowHTML":true,"outputs":0,"topic":"","x":1590,"y":1000,"wires":[]},{"id":"8a2854c.cb931a8","type":"inject","z":"c7a9e01b.3778c","name":"Pierre","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"title\":\"<b>Pierre</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>23.07.2020</b></font color> um <font color=\\\"yellow\\\"><b>23.17 Uhr</b>.\",\"icon\":null}]","payloadType":"json","x":1230,"y":980,"wires":[["415371c4.bf4fd"]]},{"id":"dd52fe2.4068","type":"inject","z":"c7a9e01b.3778c","name":"Alessandro","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"title\":\"<b>Alessandro</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>21.07.2020</b></font color> um <font color=\\\"yellow\\\"><b>11.32 Uhr</b>.\",\"icon\":null}]","payloadType":"json","x":1220,"y":1020,"wires":[["415371c4.bf4fd"]]},{"id":"bb9f2da2.5fec9","type":"ui_group","z":"","name":"Letzte Benutzer","tab":"11f55352.a4e0dd","order":1,"disp":true,"width":"14","collapse":false},{"id":"11f55352.a4e0dd","type":"ui_tab","z":"","name":"Log","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

This stacks the messages like i want, but i dont know how to format the ring-buffer output to work with the ui-list:

[{"id":"108cb558.2669fb","type":"ui_list","z":"c7a9e01b.3778c","group":"bb9f2da2.5fec9","name":"","order":1,"width":"12","height":"5","lineType":"two","actionType":"none","allowHTML":true,"outputs":0,"topic":"","x":1590,"y":1140,"wires":[]},{"id":"9206a3c4.fe052","type":"inject","z":"c7a9e01b.3778c","name":"Pierre","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"title\":\"<b>Pierre</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>23.07.2020</b></font color> um <font color=\\\"yellow\\\"><b>23.17 Uhr</b>.\",\"icon\":null}]","payloadType":"json","x":1230,"y":1120,"wires":[["d6d7d8d.c507528"]]},{"id":"590281b7.b8aa","type":"inject","z":"c7a9e01b.3778c","name":"Alessandro","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"title\":\"<b>Alessandro</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>21.07.2020</b></font color> um <font color=\\\"yellow\\\"><b>11.32 Uhr</b>.\",\"icon\":null}]","payloadType":"json","x":1220,"y":1160,"wires":[["d6d7d8d.c507528"]]},{"id":"d6d7d8d.c507528","type":"ring-buffer","z":"c7a9e01b.3778c","name":"","capacity":"100","order":"new-to-old","sendOnlyIfFull":false,"pushAfterClear":false,"extra":false,"perTopic":false,"x":1420,"y":1140,"wires":[["108cb558.2669fb"]]},{"id":"bb9f2da2.5fec9","type":"ui_group","z":"","name":"Letzte Benutzer","tab":"11f55352.a4e0dd","order":1,"disp":true,"width":"14","collapse":false},{"id":"11f55352.a4e0dd","type":"ui_tab","z":"","name":"Log","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

thank you!

Please edit your post above after reading this - How to share code or flow json

Hey Paul, sorry for that, now it should be right formattet!

1 Like

Note that the ring buffer node will push each piece of data as an element of an array. The ui_list expect exactly that, an array of objects. Your second flow is not working for a subtle reason. You are injecting an array of objects to the ring buffer. If you change the flow to inject a single object (instead of an array) it will work.

Probably a flow is worth one thousand words. I changed only the way you inject the data.

[{"id":"d2747612.7225d8","type":"ui_list","z":"85385f4e.6ebc6","group":"b8a2179e.8899a8","name":"","order":1,"width":"12","height":"5","lineType":"two","actionType":"none","allowHTML":true,"x":610,"y":160,"wires":[]},{"id":"a3498625.f08a18","type":"inject","z":"85385f4e.6ebc6","name":"Pierre","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"title\":\"<b>Pierre</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>23.07.2020</b></font color> um <font color=\\\"yellow\\\"><b>23.17 Uhr</b>.\",\"icon\":null}","payloadType":"json","x":250,"y":140,"wires":[["a8833634.d727d8"]]},{"id":"11f53cc2.7ff343","type":"inject","z":"85385f4e.6ebc6","name":"Alessandro","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"title\":\"<b>Alessandro</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>21.07.2020</b></font color> um <font color=\\\"yellow\\\"><b>11.32 Uhr</b>.\",\"icon\":null}","payloadType":"json","x":240,"y":180,"wires":[["a8833634.d727d8"]]},{"id":"a8833634.d727d8","type":"ring-buffer","z":"85385f4e.6ebc6","name":"","capacity":"100","order":"new-to-old","sendOnlyIfFull":false,"pushAfterClear":false,"extra":false,"perTopic":false,"x":440,"y":160,"wires":[["d2747612.7225d8","eef86ec7.86b8a"]]},{"id":"eef86ec7.86b8a","type":"debug","z":"85385f4e.6ebc6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":220,"wires":[]},{"id":"b8a2179e.8899a8","type":"ui_group","z":"","name":"Letzte Benutzer","tab":"63f44113.80ba3","order":1,"disp":true,"width":"14","collapse":false},{"id":"63f44113.80ba3","type":"ui_tab","z":"","name":"Log","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
1 Like

Thank you very much Andrei :smiley:

I'm a bit slow today :man_facepalming:

Now i have another question and i hope you can help me again.

i now use a template node and put in the JSON like in the inject node before, now when i push the template with an standart timestamp inject node, it works too =)

[{"id":"f71dbe35.86004","type":"ui_list","z":"c7a9e01b.3778c","group":"db5d92b.b4f487","name":"","order":1,"width":"14","height":"5","lineType":"two","actionType":"none","allowHTML":true,"outputs":0,"topic":"","x":1990,"y":980,"wires":[]},{"id":"9faee303.c17f5","type":"ring-buffer","z":"c7a9e01b.3778c","name":"","capacity":"100","order":"new-to-old","sendOnlyIfFull":false,"pushAfterClear":false,"extra":false,"perTopic":false,"x":1820,"y":980,"wires":[["f71dbe35.86004","31039bad.921614"]]},{"id":"31039bad.921614","type":"debug","z":"c7a9e01b.3778c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2000,"y":1040,"wires":[]},{"id":"a21c3a19.c00f98","type":"template","z":"c7a9e01b.3778c","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"plain","template":"{\"title\":\"<b>Pierre</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>22.07</b></font color> um <font color=\\\"yellow\\\"><b>23.17 Uhr</b>.\",\"icon\":null}","output":"json","x":1620,"y":980,"wires":[["9faee303.c17f5"]]},{"id":"f896f2d7.199e9","type":"inject","z":"c7a9e01b.3778c","name":"","props":[{"p":"payload"},{"p":"name","v":"Pierre","vt":"str"},{"p":"time","v":"23.08","vt":"str"},{"p":"date","v":"22.07.2020","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1440,"y":980,"wires":[["a21c3a19.c00f98"]]},{"id":"db5d92b.b4f487","type":"ui_group","z":"","name":"Letzte Benutzer","tab":"ed5bb1a8.a2d52","order":1,"disp":true,"width":"14","collapse":false},{"id":"ed5bb1a8.a2d52","type":"ui_tab","z":"","name":"Log","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Next step is to change the parameters in the template node dynamic.... but im not getting the infos from the inject node for msg.name, msg.time and msg.date displayed right =(

[{"id":"f33bd027.b856","type":"ui_list","z":"c7a9e01b.3778c","group":"db5d92b.b4f487","name":"","order":1,"width":"14","height":"5","lineType":"two","actionType":"none","allowHTML":true,"outputs":0,"topic":"","x":1990,"y":800,"wires":[]},{"id":"60b3308d.d1127","type":"ring-buffer","z":"c7a9e01b.3778c","name":"","capacity":"100","order":"new-to-old","sendOnlyIfFull":false,"pushAfterClear":false,"extra":false,"perTopic":false,"x":1820,"y":800,"wires":[["f33bd027.b856","9f90d6ae.470d98"]]},{"id":"9f90d6ae.470d98","type":"debug","z":"c7a9e01b.3778c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2000,"y":860,"wires":[]},{"id":"18b68885.624857","type":"template","z":"c7a9e01b.3778c","name":"","field":"payload","fieldType":"msg","format":"json","syntax":"plain","template":"{\"title\":\"<b>{{msg.name}}</b>\",\"description\":\"Am <font color=\\\"yellow\\\"><b>{{msg.date}}</b></font color> um <font color=\\\"yellow\\\"><b>{{msg.time}}</b>.\",\"icon\":null}","output":"json","x":1620,"y":800,"wires":[["60b3308d.d1127"]]},{"id":"355f59b0.eb91e6","type":"inject","z":"c7a9e01b.3778c","name":"","props":[{"p":"payload"},{"p":"name","v":"Pierre","vt":"str"},{"p":"time","v":"23.08","vt":"str"},{"p":"date","v":"22.07.2020","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1440,"y":800,"wires":[["18b68885.624857"]]},{"id":"db5d92b.b4f487","type":"ui_group","z":"","name":"Letzte Benutzer","tab":"ed5bb1a8.a2d52","order":1,"disp":true,"width":"14","collapse":false},{"id":"ed5bb1a8.a2d52","type":"ui_tab","z":"","name":"Log","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

With a function instead of the template node also no luck =(

[{"id":"f71dbe35.86004","type":"ui_list","z":"c7a9e01b.3778c","group":"db5d92b.b4f487","name":"","order":1,"width":"14","height":"5","lineType":"two","actionType":"none","allowHTML":true,"outputs":0,"topic":"","x":1990,"y":980,"wires":[]},{"id":"9faee303.c17f5","type":"ring-buffer","z":"c7a9e01b.3778c","name":"","capacity":"100","order":"new-to-old","sendOnlyIfFull":false,"pushAfterClear":false,"extra":false,"perTopic":false,"x":1820,"y":980,"wires":[["f71dbe35.86004","31039bad.921614"]]},{"id":"31039bad.921614","type":"debug","z":"c7a9e01b.3778c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2000,"y":1040,"wires":[]},{"id":"f896f2d7.199e9","type":"inject","z":"c7a9e01b.3778c","name":"","props":[{"p":"payload"},{"p":"name","v":"Pierre","vt":"str"},{"p":"time","v":"23.08","vt":"str"},{"p":"date","v":"22.07.2020","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1440,"y":980,"wires":[["73c1b708.a0d148"]]},{"id":"73c1b708.a0d148","type":"function","z":"c7a9e01b.3778c","name":"","func":"msg.payload = {\n    \"title\": \"<b>msg.name</b>\",\n    \"description\": \"Am <font color=\\\"yellow\\\"><b>msg.date</b></font color> um <font color=\\\"yellow\\\"><b>msg.time</b>.\",\n    \"icon\": null\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1620,"y":980,"wires":[["9faee303.c17f5"]]},{"id":"db5d92b.b4f487","type":"ui_group","z":"","name":"Letzte Benutzer","tab":"ed5bb1a8.a2d52","order":1,"disp":true,"width":"14","collapse":false},{"id":"ed5bb1a8.a2d52","type":"ui_tab","z":"","name":"Log","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Thank you very much again!

Usually, to access msg items in the template, leave off the msg. part.

e.g. if your debug shows values you want in msg.date then put {{date}} in the template. if your debug shows values you want in msg.payload.date then put {{payload.date}} in the template.

2 Likes

Thank you steve, i will test it, when iam at home from work. =)

Further to what Steve explained above make sure you configure the template node as below:

a-01

1 Like

Thank you both very much! Works like a charm!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.