Feature request for RBE node

situation:
I have sensor which gives a lot of output, and it logs to a graph.
Many points will slow down the graph, and the output does not change often - but when it does I want to see it.

I use the RBE node to reduce the amount of data in the graph, but:
If the value does not change for 5 hours and then suddenly spikes, I get an ugly and incorrect interpolation from the last point (5 hours ago) to the new spike-value. It shows a slope over 5 hours when in reality, the signal was steady and only spiked after 5 hours.

Feature request:
Can you make the RBE node either

  • so that it outputs some values, like at least every N seconds, or at least every Nth value?
    It would be in effect a data-reducer but not a 100% limiter.
  • or so that when the value changes it quickly outputs the last 'normal' value, followed by the spike? That way graph- interpolation would be correct.

You can achieve this with a trigger node after the RBE...

image

Or maybe a Delay node in Rate Limit mode would be better for you, rather than an RBE node.

Or this function, which combines a Rate Limit and RBE so that the output is limited to a certain rate unless the input changes, in which case the new value is sent immediately.

onst minInterval = 5000       // min interval between outputs, msec
const previous = context.get("previous") || {timestamp: 0}
const now = new Date().getTime()
if ( msg.payload == previous.value  && (now - previous.timestamp) < minInterval )
{
    // same value as last one and too soon to send again, so send nothing
    msg = null
} else {
    previous.timestamp = now
    previous.value = msg.payload
    context.set("previous", previous)
}
return msg;

Cool! I use trigger nodes but I had not thought of this!!

No, that won't work, but thanks.
It's interesting to me when the value changes.
Rate limit will simply drop messages regardless of their value.

A step line chart might be better than sending unnecessary duplicate points.

image

image

1 Like

The function I posted solves that problem. The trigger node solution has the potential problem that if the sensor fails so that it stops sending data then the graph will keep going as if there is good data. The function will only keep sending values provided data keeps coming in. Whether that matters depends on your requirement.

The step option in the graph node is the simplest answer

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