I found a strange behaviour when using the ui_table node. I can fix the code in two different ways. The first workaround will fix it in definitive but I don´t know why it works. The second way will fix it in a surprising way but when I roll back the solution is not possible to observe the issue again (surprisingly too).
Before I explain the fixes can someone be kind enough to try to confirm the issue. I want to make sure it is not specific to my environment in the the first place.
This is the minimum flow I could write to try to reproduce the issue.
The first inject node initializes an array of objects and pass it to the ui_table.
I added three more inject nodes to be able to modify data dynamically.
At the initialization the table will be populated as below.
Now, try to clik on the other inject buttons, one at a time. Do you see any update in the column "Power" in the dashboard while after pressing the last three inject nodes ?
Testing flow:
[{"id":"23737d07.4f1e22","type":"tab","label":"Flow 8","disabled":false,"info":""},{"id":"cb321e5a.ad2e5","type":"ui_table","z":"23737d07.4f1e22","group":"e18d18ee.a6f4f8","name":"Grid","order":2,"width":"16","height":"6","columns":[],"outputs":0,"cts":false,"x":1230,"y":340,"wires":[]},{"id":"20a7e1d9.0d10de","type":"function","z":"23737d07.4f1e22","name":"Change object","func":"// grid is an array of objects\nlet grid = flow.get(\"gridmem\") || [];\n\n\n// Find index of Sensor\nlet sRow = grid.findIndex(\n (ele,index) => ele.Sensor == msg.payload.Sensor\n);\n\n\n// Add a dynamic prperty to the array element\ngrid[sRow][\"Power\"] = \"voltage * current\";\n\n// store modified array to the context\nflow.set(\"gridmem\", grid);\n\nnode.warn(grid);\n\nmsg.payload = grid; //BAD ?\n\n//msg.payload = [...grid]; // Always OK\n\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":340,"wires":[["db2bbd3.7b40f4","e63ac256.0764f","6e8362f0.ccc5fc","8a75d2a5.2752f"]]},{"id":"ec6b8a10.0f9508","type":"inject","z":"23737d07.4f1e22","name":"Change sensor S1","topic":"","payload":"{\"City\":\"Albany\",\"Sensor\":\"S1\",\"Voltage\":220,\"Current\":10}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":280,"wires":[["20a7e1d9.0d10de"]]},{"id":"e63ac256.0764f","type":"debug","z":"23737d07.4f1e22","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload[0].Power","targetType":"msg","x":840,"y":400,"wires":[]},{"id":"25908860.5df998","type":"inject","z":"23737d07.4f1e22","name":"Initialize sensors S1, S2, S3","topic":"","payload":"[{\"City\":\"A\",\"Sensor\":\"S1\",\"Voltage\":0,\"Current\":0,\"Power\":0},{\"City\":\"A\",\"Sensor\":\"S2\",\"Voltage\":0,\"Current\":0,\"Power\":0},{\"City\":\"A\",\"Sensor\":\"S3\",\"Voltage\":0,\"Current\":0,\"Power\":0}]","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":360,"y":220,"wires":[["b6b4592.77713a8"]]},{"id":"b6b4592.77713a8","type":"change","z":"23737d07.4f1e22","name":"","rules":[{"t":"set","p":"gridmem","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":220,"wires":[["db2bbd3.7b40f4"]]},{"id":"a030f51d.f62e58","type":"inject","z":"23737d07.4f1e22","name":"Change sensor S2","topic":"","payload":"{\"City\":\"Albany\",\"Sensor\":\"S2\",\"Voltage\":220,\"Current\":20}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":340,"wires":[["20a7e1d9.0d10de"]]},{"id":"b6ae383c.350c28","type":"inject","z":"23737d07.4f1e22","name":"Change sensor S3","topic":"","payload":"{\"City\":\"Albany\",\"Sensor\":\"S3\",\"Voltage\":220,\"Current\":30}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":400,"wires":[["20a7e1d9.0d10de"]]},{"id":"6e8362f0.ccc5fc","type":"debug","z":"23737d07.4f1e22","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload[1].Power","targetType":"msg","x":840,"y":460,"wires":[]},{"id":"8a75d2a5.2752f","type":"debug","z":"23737d07.4f1e22","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload[2].Power","targetType":"msg","x":840,"y":520,"wires":[]},{"id":"db2bbd3.7b40f4","type":"change","z":"23737d07.4f1e22","name":"ui_control","rules":[{"t":"set","p":"ui_control.tabulator.columns","pt":"msg","to":"[{\"title\":\"City\",\"field\":\"City\"},{\"title\":\"Sensor\",\"field\":\"Sensor\"},{\"title\":\"Voltage\",\"field\":\"Voltage\"},{\"title\":\"Current\",\"field\":\"Current\"},{\"title\":\"Power\",\"field\":\"Power\"}]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":340,"wires":[["cb321e5a.ad2e5"]]},{"id":"e18d18ee.a6f4f8","type":"ui_group","z":"","name":"G2","tab":"783458b.f2fefa8","order":1,"disp":false,"width":"28","collapse":false},{"id":"783458b.f2fefa8","type":"ui_tab","z":"","name":"GRID","icon":"dashboard","disabled":false,"hidden":false}]