Looking at the code everything looks totally fine. It will format the content and style the color of the text.
I believe you like to implement something like "last seen" or "last update". I think you can't do it with ui-table run on its own. But if you send regular updates in the interval you need it isn't difficult:
The trigger simulates a new update (reset last seen with a new timestamp). update Data does simple "formatting". The trigger node resents the last seen timestamp and delta does a simple Date.now()-timestamp
The formatter then looks like this (I reduced it to seconds for faster debugging)
function (cell, formatterParams, onRendered) {
let updatedSince = Number(cell.getValue());
if (Number.isNaN(updatedSince)) {
cell.getElement().style.color = 'red';
return 'never';
}
if (updatedSince < 10) {
cell.getElement().style.color = 'lime';
return updatedSince + ' ' + 's (<10)';
} else if (updatedSince < 20) {
cell.getElement().style.color = 'orange';
return updatedSince + ' ' + 's (<20)';
}
cell.getElement().style.color = 'coral';
return updatedSince + ' ' + 's (>20)';
}
Simply feed this flow into the ui-table-handler and add the "lastSeen" column
[{"id":"b6d568762ff16077","type":"trigger","z":"d2952ff54c89c139","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-1","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":500,"y":1540,"wires":[["333515516f7ae884"]]},{"id":"df10a25a5973aef6","type":"inject","z":"d2952ff54c89c139","name":"trigger","props":[{"p":"payload"},{"p":"index","v":"1","vt":"num"},{"p":"column","v":"lastSeen","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":170,"y":1540,"wires":[["d449b1a7538a3949"]]},{"id":"d449b1a7538a3949","type":"function","z":"d2952ff54c89c139","name":"update Data","func":"let value = msg.payload;\nmsg.payload = { id: msg.index};\nmsg.payload[msg.column] = value;\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\ncontext.set('index',0);","finalize":"","libs":[],"x":310,"y":1540,"wires":[["b6d568762ff16077"]]},{"id":"b56f7f19a054d87b","type":"debug","z":"d2952ff54c89c139","name":"update","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":1540,"wires":[]},{"id":"89ac1fed6b1e1132","type":"inject","z":"d2952ff54c89c139","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":330,"y":1580,"wires":[["b6d568762ff16077"]]},{"id":"333515516f7ae884","type":"function","z":"d2952ff54c89c139","name":"delta","func":"msg.payload.lastSeen = Math.floor((Date.now() - msg.payload.lastSeen) / 1000);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":1540,"wires":[["b952ac65.8ddfb","b56f7f19a054d87b"]]}]
I first tried only to resend the "lastSeen" timestamp. This does not work because the cell formatter is only triggered if the value changes. For many rows you should think about sending an array of all rows every minute (as this is your desired scope) to the table handler.
A last tip: Use a "unconnected" function node to edit your callbacks and then copy past the function into your JSON via the Visual Editor. By doing so you can take advantage of the syntax checking (i.e. undeclared variables) and don't worry about escaping inverted commas ... Don't use comments as they might break the complete code behind the comment as CR seams not to be translated into /n