Hello to all.
I try to format my battery response in a table format in the dashboard.
I have already succeeded but at the cost of a "lamentable" programming (see below the result, it looks nice but it's ugly on the programming side). Indeed I programmed in "hard coded" only for 4 batteries.
But there can be up to 16 pieces. So I want to redo my code so that it is adaptable and dynamic to the number of batteries.
To determine how many batteries there are, just find the lines where the word "Absent" is present and delete them from the array.
Then recover the new table without these useless lines and display them in the dashboard table
So in summary, can you help me to:
- Eliminate the rows where the word "Absent" is present into the array
- Split each row of the remaining table so that each part fits in its respective column by creating a JSON for the UI_TABLE node
Here is the debug of what I have as debug values to allow to reproduce my situation
Here is the array value of 16 lines, (the sign ↵ is automatically replaced by \r\r\n by doing a copy/paste)
["1 51384 18209 29500 28800 29600 3417 3437 Charge Normal Normal Normal 92% 2022-08-11 20:49:03 Normal Normal 28900 Normal \r\r\n","2 51364 19623 29300 28700 29400 3418 3437 Charge Normal Normal Normal 92% 2022-08-11 20:49:02 Normal Normal 29100 Normal \r\r\n","3 51412 15537 27100 27300 27800 3419 3447 Charge Normal Normal Normal 89% 2022-08-11 20:49:01 Normal Normal 27400 Normal \r\r\n","4 - - - - - - - Absent - - - - - - - \r\r\n","5 - - - - - - - Absent - - - - - - - \r\r\n","6 - - - - - - - Absent - - - - - - - \r\r\n","7 - - - - - - - Absent - - - - - - - \r\r\n","8 - - - - - - - Absent - - - - - - - \r\r\n","9 - - - - - - - Absent - - - - - - - \r\r\n","10 - - - - - - - Absent - - - - - - - \r\r\n","11 - - - - - - - Absent - - - - - - - \r\r\n","12 - - - - - - - Absent - - - - - - - \r\r\n","13 - - - - - - - Absent - - - - - - - \r\r\n","14 - - - - - - - Absent - - - - - - - \r\r\n","15 - - - - - - - Absent - - - - - - - \r\r\n","16 - - - - - - - Absent - - - - - - - \r\n"]
Here is the value of one of the 16 line array:
1 51680 18089 29600 29000 29800 3429 3466 Charge Normal Normal Normal 95% 2022-08-11 20:51:29 Normal Normal 29100 Normal
Bellow, is what I would like to achieve at the end, what is already working but at the cost of a calamitous and not evolving programming. I am not at all comfortable with the manipulation of arrays.
I hope you were able to follow my explanations