Pause flow during certain hours of the day

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?

[{"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":""}]

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
Screen Shot 05-22-21 at 08.07 AM 002


Screen Shot 05-22-21 at 08.08 AM

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

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

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

Johannes

2 Likes

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

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.

1 Like

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