# Sleep function no related to time, related to values

**URL:** <https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299>\
**Category:** General\
**Created:** [18 July 2020 19:56 UTC](https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299 "2020-07-18T19:56:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalo](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lalo](https://discourse.nodered.org/u/lalo)\
**Post date:** [18 July 2020 19:56 UTC](https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299/1 "2020-07-18T19:56:42Z")

</div>

Hi, guys I want to have like a sleep function so basically I'm reading values for example from 0 to 50 so when the value is close to 0 I need some msg.payload interrupt to no send any msg, and when it approximates to 50 will activate again the msg.payload. Some help?  
Any examples?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 July 2020 20:02 UTC](https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299/2 "2020-07-18T20:02:10Z")

</div>

Why not send the reading to a `switch` node and test for \< 5 and \> 45. If it is less than five don't do anything and if it is greater than 45 let the message continue.

---

<div class="post-metadata">

**Author:** ![lalo](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lalo](https://discourse.nodered.org/u/lalo)\
**Post date:** [18 July 2020 20:03 UTC](https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299/3 "2020-07-18T20:03:12Z")

</div>

like a switch case?  
explait it more please

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 July 2020 20:13 UTC](https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299/4 "2020-07-18T20:13:31Z")

</div>

Try playing with the `switch` node to see how it works. For testing connect two inject nodes to it and set them to each inject a number. Connect a debug to the outputs of the change node and give it a test.

---

<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:** [16 September 2020 20:13 UTC](https://discourse.nodered.org/t/sleep-function-no-related-to-time-related-to-values/30299/5 "2020-09-16T20:13:32Z")

</div>

Closed on 16 September 2020 20:13 UTC

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