# A handy little routine/flow to monitor for sustained values over a time

**URL:** <https://discourse.nodered.org/t/a-handy-little-routine-flow-to-monitor-for-sustained-values-over-a-time/32464>\
**Category:** Share Your Projects\
**Created:** [5 September 2020 05:08 UTC](https://discourse.nodered.org/t/a-handy-little-routine-flow-to-monitor-for-sustained-values-over-a-time/32464 "2020-09-05T05:08:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [5 September 2020 05:08 UTC](https://discourse.nodered.org/t/a-handy-little-routine-flow-to-monitor-for-sustained-values-over-a-time/32464/1 "2020-09-05T05:08:23Z")

</div>

Instructions in the `comment` nodes indicated with a `*`.

As is, it is set to the extremes, so may not be too handy, but it easily editable.

# Concept:

You are getting data coming in (values/numbers) that have a range.  
In this example 0 -\> 100

0 is not useful.  
100 is also not too helpful.

So the idea is that if signals (messages) are received for (say) 40 seconds that are between 1 and 99 (inclusive) you will get an output.

Sorry I didn't set anything in the `output` node. Too variable.

You can adjust the acceptable range by editing the `switch` node.  
The **middle** output is the acceptable range.  
The first and last outputs are outside acceptable values and are needed to be used.

If a value **is** outside the range, the outputs are taken to a `change` node and a `reset` message is constructed and resets the `trigger` node.

The `trigger` node is to be edited for the time period you wish the values to be covered.  
(Obviously the more signals the better)

I know there are nodes that could do this similar.  
But for the point of sharing and helping people: here is a small flow (routine) to do just that.

```auto
[{"id":"f62cfcc1.ecaa38","type":"trigger","z":"68e3655f.b606b4","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"40","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":530,"y":1680,"wires":[["eeeb3617.de0668","20244a41.1c6a86"]]},{"id":"621af0cb.13e2c","type":"switch","z":"68e3655f.b606b4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"gt","v":"0","vt":"num"},{"t":"eq","v":"100","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":330,"y":1680,"wires":[["cabd0990.6a169"],["f62cfcc1.ecaa38"],["cabd0990.6a169"]]},{"id":"cabd0990.6a169","type":"change","z":"68e3655f.b606b4","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":1760,"wires":[["f62cfcc1.ecaa38","7e940055.b8258"]]},{"id":"eeeb3617.de0668","type":"debug","z":"68e3655f.b606b4","name":"Sustained signal received.","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":1640,"wires":[]},{"id":"7e940055.b8258","type":"trigger","z":"68e3655f.b606b4","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"1","extend":false,"units":"s","reset":"","bytopic":"all","name":"Reset indicator","x":540,"y":1760,"wires":[[]]},{"id":"8999443b.debb08","type":"comment","z":"68e3655f.b606b4","name":"Sustained health indicator *","info":"Used to detect ongoing signals that are acceptable for health.\n\nEdit the `switch` node for the range.\nand edit the `trigger` node for how long it needs to be valid.\n","x":460,"y":1600,"wires":[]},{"id":"cfb2511d.b8ba98","type":"function","z":"68e3655f.b606b4","name":"Input","func":"\nreturn msg;","outputs":1,"noerr":0,"x":200,"y":1680,"wires":[["621af0cb.13e2c"]]},{"id":"c3e4902d.4afc48","type":"comment","z":"68e3655f.b606b4","name":"Optional *","info":"This node is just if you want to see what's going on from the edit screen if there are signals received that are resetting the `trigger` node.","x":530,"y":1720,"wires":[]},{"id":"20244a41.1c6a86","type":"function","z":"68e3655f.b606b4","name":"Output","func":"\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":1680,"wires":[[]]}]

```

 ![Screenshot from 2020-09-05 15-07-14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4cd0dd3799465cdf4e8b9ad6e33cacc89d1a28b4.png)

---

<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:** [4 November 2020 05:08 UTC](https://discourse.nodered.org/t/a-handy-little-routine-flow-to-monitor-for-sustained-values-over-a-time/32464/2 "2020-11-04T05:08:27Z")

</div>

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