Guidance on evaluating several inputs to one process

Hi all,
I'm looking for some guidance/best practice when evaluating several similar inputs.
I have thee Luminance level inputs (2no Zigbee & 1 Wifi) lux meters. I use the Lux level to trigger or influence flows for such mundane tasks like zone lighting (Light level and colour temperature).
I have 3 LUX meters because I have found that individually they can be unreliable, either they drop offline completely or seem to freeze on a value for hours.
Whilst I intend to investigate the causes for the random freezes, I's made me think about how best to derive a true lux value from 2 or more competing inputs.
This could just as easily be several temp probes to ward against probe failure.

Open to any ideas on the best methods, but keen to avoid complicated code given the premise of NodeRed being object oriented rather than code heavy.

Thanks in advance.
image

I would do this by making sure the three inputs have unique topics then feeding them into a Join node configured as below to give you, every time you get any input, a message containing all three values. Then you can run whatever algorithm you want to ignore faulty values and (possibly) average the rest.

Thanks, it's the 'algorithm' I need help with. Some ideas ect...

First you need to work out, in words, what you want to do. For example you will need to know how to identify faulty values in order to ignore them. There is no generic answer to that because it depends on the type of fault conditions that the particular sensor/measuring system that you are using is prone to.

Generally it's freezing, i.e no longer changing, but that's not foolproof. I do have three, so how about take an average of the three and discard the outlier...?

When you say they are freezing do you mean they stop sending readings or they keep sending but it is wrong?

They are devices hosted by Home Assistant, so NR gets a response from HA, but that response is not always valid. If a sensor has frozen (It's output value remains unchanged) it's not obvious to NR as HA will still respond with a value.

Looks like a reason not to use HA if it just keeps sending the last reading when it is not getting new values.

One way might be to always take the average of the two that are closest together and ignore the third one.

1 Like

If one or more are freezing, there will be no value. Personally, I would use a function node (but then I'm a bit of an old-fashioned programmer :slight_smile:)

Record each - yes each input needs a different topic - and if the value is sensible, update an object variable containing the 3 sensors values. Then take the average of the current 3 values.

That would be simplest I think though it might be thrown out if one of the sensors stays offline for any amount. In that case, you would need to record the values along with a timestamp and only take the values that have a recent timestamp for the average.

That doesn't agree with what @dougle03 said, which was that HA gives him readings even when it is frozen. I can't comment as I don't know about HA.

I'd already written that before I saw his comment about HA. Agree that if HA is getting in the way, ditch HA!

@dougle03 I don't know what the values look like from those sensors but if you expect a small amount of noise, so having exactly the same value over a significant time would always indicate something is wrong, then (before the Join node), if you feed the values through an RBE node so it only sends on changed values and then into a Trigger node set to Send original message, then Wait for 2 minutes (or whatever is appropriate) and then send an illegal value (-1 for example), but have Extend Delay set then all the time new values keep coming it it will pass them on but if the value freezes for two minutes it will send the illegal value. Then after the Join node, in the Function node you can reject the illegal values and take the average of the others.

1 Like