Batch function with averaging

Hi,

in Node-RED there is node called "batch" where I can group messages by time interval. But I need to average every field that is received in meantime repeatedly. The problem is when messages are sent randomly (when values are changed). I can't define in advance the count of messages and even the field names.

It is possible to write that batch function with grouping messages and averaging values"

Thank you

You could use batch and join to get a msg.payload that has all of the values over your set time in an array that you could then calculate an average from (using a change node and JSONata or using a function node). That has the advantage of only needing core nodes.

If you are happy installing another node, the node-red-contrib-calculate node should do what you want I think.

node-red-contrib-calculate working perfectly ! thank you

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