Node-red-contrib-influxdb : influxdb batch : not sure about processing an array of data

I have seen some discussions regarding using the batch node for influxdb but have not got my head around it yet.

I have an array of data in msg.payload that I want to use the batch node to write an entry to a table but replacing the time value with a value in one of the array fields:

A short array of my data is below:


There can be a variable number of array entries.

for each of these, I would like to write a new influxdb sensor entry with the following fields:

time: this set to "readings_date_str" value, I guess at 00:00:00 time on that day
elec_cons: same as array input
elec_cost_pounds: same as array input
elec_standing_charge_pence: same as array input
elec_tariff_pence: same as array input
gas_cons: same as array input
gas_cost_pounds: same as array input
gas_standing_charge_pence: same as array input
gas_tariff_pence: same as array input
total_cost: set to "value"

I don't know how an array can be read and each processed by the batch node (although I assume this is built as a payload in a function node?) plus I am also unsure about measurement and tag fields. What do these really mean? Are the expected values in some standard list of values?

There are mentions of iterating through arrays in discussions but not many good examples of how that is actually coded.

That is not really a node-red issue, it is an influxdb issue, but basically anything that is a process measurement should be a field, and anything that is a identifier of some sort, such as meter id, batch number, operator name and so on should be a tag. Tags are automatically indexed so that you can efficiently search by, for example, meter_id in a query. Possible, therefore, domain, entity_id and friendly_name_str should be tags, if you need to record them that is.

As to formatting the data for the batch node, is all the data in the array to go in the same influxdb measurement? If so then it may be easier to use the normal influxdb out node, which can be given a set of data in an array as described in the help text. If you look at the node's page on the node-red flows site the last example in the section on the influxdb out node shows exactly that.

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