Need help with extracting values in Function node

Many thanks to @Colin and @UnborN for "teaching me to fish"! :purple_heart:

1 Like

I realise was confused about why you were using the Join node. I thought you wanted to put them all into one measurement, in which case you would end up with a payload something like

[
  {
    power: 25,
    volts:  230,
    power: 15.3,
    cumulative_power: 1234.4
  },
  {
    device: "1234",
  }
]

Which is fed into an Influx Out node.
But it seems you are writing them to separate measurements, in which case there is definitely no need to use the join node. So I suggest taking that out and feeding all the incoming values into a simple function node which returns a message with msg.measurement set to the measurement determined from the topic, and a payload consisting of something like

{
  value: 25.75
},
{
  device: "1234",
}

So identical message contents for them all, the only difference is the measurement. No need to mess about using a Join node and then building the array in the function node.
In addition, don't put the units and type as tags in the record, there is no point doing that and it doubles the amount of data in each record. For any measurement those should always be the same.

[Edit] and of course the function returns nothing if the value is not valid for some reason.

2 Likes

:rofl:
Oh, good grief! Just when I thought I had what I was after :roll_eyes:

Silly me didn't actually :eyes: at individual records to verify what was there but it seems obvious now that you point it out. At least now I know how to rearrange things.

Thank you, @Colin

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