# Min x minutes; value \>= y or brightness value must have reached a value x minutes, then value 'true' is displayed

**URL:** <https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045>\
**Category:** General\
**Created:** [15 October 2023 11:25 UTC](https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045 "2023-10-15T11:25:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![F11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/f11/32/73913_2.png) [@F11](https://discourse.nodered.org/u/F11)\
**Post date:** [15 October 2023 11:25 UTC](https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045/1 "2023-10-15T11:25:29Z")

</div>

Hello  
I am still a newbie in node red and have a little problem.  
I want to evaluate the brightness for the control of my shutters. For this I have a Lux sensor whose data I smooth with a Smooth Node. The result is already as I expected, that there are not so many and high outliers.  
But now I wanted that for the control at sun, the Lux value at least y minutes does not fall \<= x Lux.  
Which node can I use for this.  
In other words, only when the sun shines with value x longer than y minutes, a 'true' should be output, otherwise 'false'.  
Instead of minutes it can also be the number of values  
many thanks already  
Greetings  
Roland

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 October 2023 12:00 UTC](https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045/2 "2023-10-15T12:00:16Z")

</div>

I would turn the lux into a boolean, then filter it so only changes pass. You can then use a trigger node to output if true for x time limit, and cancel if false.  
e.g

```auto
[{"id":"66db13a174d0e2c2","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload >= 30","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":1340,"wires":[["935f052bde6d386f"]]},{"id":"192f88434812be55","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":110,"y":1320,"wires":[["66db13a174d0e2c2"]]},{"id":"8046a2b36c02ca27","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":110,"y":1360,"wires":[["66db13a174d0e2c2"]]},{"id":"935f052bde6d386f","type":"rbe","z":"d1395164b4eec73e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":430,"y":1340,"wires":[["496359ffd82aac09"]]},{"id":"496359ffd82aac09","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"false","bytopic":"all","topic":"topic","outputs":1,"x":590,"y":1340,"wires":[["ae98bcd52b983f26"]]},{"id":"ae98bcd52b983f26","type":"debug","z":"d1395164b4eec73e","name":"debug 346","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":1400,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 October 2023 12:03 UTC](https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045/3 "2023-10-15T12:03:49Z")

</div>

Here is an example using the trigger node to create your "y minutes" delay (But I used 10 seconds)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/20e63c1183cb257c1e729f1ab5abaf3c173ea66d.png)

```auto
[{"id":"76a1b73b.183d68","type":"inject","z":"2b607c7076581b35","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":90,"y":40,"wires":[["4603783e173d2c21"]]},{"id":"65d40db8.a06334","type":"debug","z":"2b607c7076581b35","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":80,"wires":[]},{"id":"6652e6559c315eb3","type":"trigger","z":"2b607c7076581b35","name":"","op1":"","op2":"true","op1type":"nul","op2type":"bool","duration":"10","extend":false,"overrideDelay":true,"units":"s","reset":"false","bytopic":"all","topic":"topic","outputs":1,"x":430,"y":40,"wires":[["65d40db8.a06334"]]},{"id":"980226acba0a15ef","type":"inject","z":"2b607c7076581b35","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":90,"y":80,"wires":[["4603783e173d2c21"]]},{"id":"9182ac22892c5c27","type":"inject","z":"2b607c7076581b35","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30","payloadType":"num","x":90,"y":120,"wires":[["4603783e173d2c21"]]},{"id":"acd9fee7bf6aff98","type":"switch","z":"2b607c7076581b35","name":">= 19?","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"19","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":240,"y":80,"wires":[["6652e6559c315eb3"],["ad35e9aeb395f7f8"]]},{"id":"ad35e9aeb395f7f8","type":"change","z":"2b607c7076581b35","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":120,"wires":[["65d40db8.a06334","6652e6559c315eb3"]]},{"id":"4603783e173d2c21","type":"junction","z":"2b607c7076581b35","x":160,"y":80,"wires":[["acd9fee7bf6aff98"]]}]

```

An input greater than 19 starts the 10sec delay, less than 20 cancels it.  
Edit - OOPS, pipped at the post!

---

<div class="post-metadata">

**Author:** ![F11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/f11/32/73913_2.png) [@F11](https://discourse.nodered.org/u/F11)\
**Post date:** [15 October 2023 19:33 UTC](https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045/4 "2023-10-15T19:33:56Z")

</div>

Hello,  
thank you very much for the explanations, I will have a look at it and try to implement it like this  
If you know how to do it, everything is easy ...

@ jbudd "Edit - OOPS, pipped at the post!"  
looks like a competition with E1cid 😉

---

<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:** [14 December 2023 19:34 UTC](https://discourse.nodered.org/t/min-x-minutes-value-y-or-brightness-value-must-have-reached-a-value-x-minutes-then-value-true-is-displayed/82045/5 "2023-12-14T19:34:10Z")

</div>

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