# Guidance on evaluating several inputs to one process

**URL:** <https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854>\
**Category:** General\
**Created:** [2 December 2020 09:43 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854 "2020-12-02T09:43:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [2 December 2020 09:43 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/1 "2020-12-02T09:43:14Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e486ae96cfc0baa4969273710f00e8f1ba02f2b.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2020 09:59 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/2 "2020-12-02T09:59:08Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/aedc5f1043949dc652469dd783d44cf79bd0c812.png)

---

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [2 December 2020 10:19 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/3 "2020-12-02T10:19:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2020 10:24 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/4 "2020-12-02T10:24:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [2 December 2020 11:45 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/5 "2020-12-02T11:45:26Z")

</div>

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...?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2020 13:45 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/6 "2020-12-02T13:45:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [2 December 2020 17:55 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/7 "2020-12-02T17:55:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2020 21:03 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/8 "2020-12-02T21:03:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 December 2020 21:58 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/9 "2020-12-02T21:58:06Z")

</div>

> [@dougle03](#):
>
> 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...?

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 🙂)

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 December 2020 10:00 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/10 "2020-12-03T10:00:27Z")

</div>

> [@TotallyInformation](#):
>
> If one or more are freezing, there will be no value

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 December 2020 13:46 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/11 "2020-12-03T13:46:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 December 2020 15:07 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/12 "2020-12-03T15:07:11Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 February 2021 15:07 UTC](https://discourse.nodered.org/t/guidance-on-evaluating-several-inputs-to-one-process/36854/13 "2021-02-01T15:07:22Z")

</div>

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