# Pause flow during certain hours of the day

**URL:** https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078
**Category:** General
**Created:** [22 May 2021 07:00 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078 "2021-05-22T07:00:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)
#### Post date: [22 May 2021 07:00 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078/1 "2021-05-22T07:00:12Z")

</div>

To switch a lamp when there is movement I use the flow below, that works fine. Now I want to adjust the flow so that the lamp does not turn on during certain hours of the day (the same hours every day).

Which node do you advise me?

 ![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a99e39129407d12879b7161f42d3ae188c3ec2c4.png)

```auto
[{"id":"eee80739.8fc608","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"118e49b6.c97376","type":"trigger","z":"eee80739.8fc608","name":"5 Minutes","op1":"ON","op2":"OFF","op1type":"str","op2type":"str","duration":"5","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":560,"y":140,"wires":[["748be118.67147"]]},{"id":"748be118.67147","type":"switch","z":"eee80739.8fc608","name":"ON/OFF","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"OFF","vt":"str"},{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":700,"y":140,"wires":[["28ccf0af.d0519"],["89247183.92256"]]},{"id":"b316f9ac.73b028","type":"mqtt in","z":"eee80739.8fc608","name":"Bridge","topic":"tele/SonoffRF1/RESULT","qos":"2","datatype":"json","broker":"e867dbc3.269d78","nl":false,"rap":true,"rh":0,"x":170,"y":140,"wires":[["1fd541b1.70a08e"]]},{"id":"1fd541b1.70a08e","type":"change","z":"eee80739.8fc608","name":"Change","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t\"RFCode\": payload.RfReceived.Data\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":140,"wires":[["60650199.ed7ac"]]},{"id":"60650199.ed7ac","type":"switch","z":"eee80739.8fc608","name":"Switch","property":"payload.RFCode","propertyType":"msg","rules":[{"t":"eq","v":"B42666","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":140,"wires":[["118e49b6.c97376"]]},{"id":"28ccf0af.d0519","type":"mqtt out","z":"eee80739.8fc608","name":"Light OFF","topic":"cmnd/Aanrecht/POWER","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e867dbc3.269d78","x":860,"y":100,"wires":[]},{"id":"89247183.92256","type":"mqtt out","z":"eee80739.8fc608","name":"Light ON","topic":"cmnd/Aanrecht/POWER","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e867dbc3.269d78","x":860,"y":180,"wires":[]},{"id":"e867dbc3.269d78","type":"mqtt-broker","name":"MQTT EchtSing","broker":"192.168.2.160","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

```

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [22 May 2021 07:15 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078/2 "2021-05-22T07:15:39Z")

</div>

It's probably an overkill for this situation - but I would use BigTimer to handle this.  
For example, I have a security lighting system that comes on from sunset to 22:00 hrs each day.  
The flows below connect into that system to act as Courtsey Lights that come on if infrared is detected between 22:00 hrs and sunrise. Big Timer sets a flow varaiable which is 'checked' in the switch node.  
Hope this is useful for you.

![Screen Shot 05-22-21 at 08.07 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33692cfa678771cc24c538627192b355416f2091.jpeg)  
 ![Screen Shot 05-22-21 at 08.07 AM 002](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d45400d140ae435d47e914a9c1984e8341b2fc9.jpeg)

 ![Screen Shot 05-22-21 at 08.07 AM 001](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1dfe52f95ff275c6aba26d0a6876fcf14411de79.jpeg)  
 ![Screen Shot 05-22-21 at 08.08 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8b6ab5940dc89f9a0cc3e26cd3216f79c771fe03.jpeg)

PS:  
You could also use the 'inject' node set to 'repeat between times' or node-red-contrib-cron-plus.

![Screen Shot 05-22-21 at 08.25 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/b/4bdf0f78339c71c2ec4f9c9ad54f01e1d29b1a64.jpeg)

---

<div class="post-metadata">

### Author: ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)
#### Post date: [22 May 2021 07:35 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078/3 "2021-05-22T07:35:21Z")

</div>

You could try and use this simple subflow i build a while back to only pass the motion message in a certain time frame. Just drop it in the flow somewhere at the start after the input of the motion sensor:

[https://flows.nodered.org/flow/fce3ff5ca0df010ab2d4e692f2e50b4e](https://flows.nodered.org/flow/fce3ff5ca0df010ab2d4e692f2e50b4e)

i also use it for this use case in my setup.

Johannes

---

<div class="post-metadata">

### Author: ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)
#### Post date: [22 May 2021 09:48 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078/4 "2021-05-22T09:48:35Z")

</div>

Thanks Dave and Johannes, I'll test both suggestions.

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [22 May 2021 10:10 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078/5 "2021-05-22T10:10:35Z")

</div>

Looking at your flow, all you would need to do is copy my flow that uses Big Timer and insert the 'switch' node somewhere after your MQTT-In node.

Hope it works for you.

---

<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: [21 July 2021 10:11 UTC](https://discourse.nodered.org/t/pause-flow-during-certain-hours-of-the-day/46078/6 "2021-07-21T10:11:30Z")

</div>

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