Payload parser assign predetermined group values to variables

Hi,

I have used a mqtt csv parser to get comma delimited values of a variable into cast number values. I use the same variable name so im getting the same variables with different values. I need to assign now predetermined group values in order to see them all in a table widget. right know they are getting the same group values and I only see one of the values in the table. Can someone please help with the code to be able to see all values in one table

const mqtt_payload = payload.find((data) => data.variable === "ids" || (data.metadata && data.metadata.mqtt_topic));if (mqtt_payload) {  const data = [    { variable: 'id',  value: Number(splitted_value[1]),},    { variable: 'id',  value: Number(splitted_value[2]),},    { variable: 'id',  value: Number(splitted_value[3]),},  ];  const group = String(new Date().getTime());  payload = payload.concat(data).map(x => ({ ...x, group }));

}

Well of course, you’re grouping all your inputs under the same variable AND under the same group/series. The widget will only display whatever data arrived last, as if the other values were crushed.

I don’t really get how’s your payload to begin with, but the case your described was that you wanted the keep the same variable, but have a different group for each input, right?

The easiest could be to add a number (perhaps an index?) to your group-timestamp while it’s in int form, then cast it to string. Altough, given how JS works you an just add a number to a string and should work lol.

const mqtt_payload = payload.find((data) => data.variable === “ids” || (data.metadata && data.metadata.mqtt_topic));

if (mqtt_payload) {

const group \= new Date().getTime();



const data \= \[

    { variable: 'id', value: Number(splitted\_value\[1\]), group: String(group + 1) },

    { variable: 'id', value: Number(splitted\_value\[2\]), group: String(group + 2) },

    { variable: 'id', value: Number(splitted\_value\[3\]), group: String(group + 3) },

\];



payload.concat(data);

}

The thing that I don’t like for this approach is that it looks somewhat dirty but it can work.

Edit: last line of code