biddster / node-red-contrib-time-range-switch

A simple Node-RED node that routes messages depending on the time.
17 stars 8 forks source link

Issues with time ranges defined by suncalc events #17

Open wilvancleve opened 6 years ago

wilvancleve commented 6 years ago

Example: time-range set from dusk til dawn.

Between dusk and midnight, condition will be true.

Between midnight and dawn, condition will not be true, and graphical interface of node indicates that the time-range event is now looking forward to the new date's dusk.

Is date being included in the range inappropriately when using suncalc events? When using hard set times, this does not occur.

biddster commented 6 years ago

@wilvancleve, please can you test 0.6.1 and let me know as I think that release will fix your problem.

Poodlepapa commented 5 years ago

I’m having an issue with the the node saying “invalid date”, and it will not pass a message on when it should. Is there a way to fix that? I’ve installed all of the dependencies and the time and date are correct on the pi. How should I try and fix this.

Thank you very much.

I should also add that everything work fine from the second output not the first

biddster commented 5 years ago

What version of node-red, nodejs and this node are you using please?

Poodlepapa commented 5 years ago

I am using node red version 0.19.5 Thank you. I am not using the latest version of this node, I'm not sure how to determine the version of the node itself, but I installed it about 2 weeks ago. Should I try the new version that was released 2 days ago?

biddster commented 5 years ago

Hmm, this is a puzzler. Can you share the config you've entered through the node-red UI?

Poodlepapa commented 5 years ago

Sure! Im just going to export the node and drop it here. let me know if you need more than that. also, I have two of those nodes in the same flow only one has the invalid date issue. Im going to export the whole thing so you have some context.

`[{"id":"f72768f0.86b438","type":"tab","label":"MQTT connections","disabled":false,"info":""},{"id":"3aedfdbd.b4b812","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Fence ","group":"f5c472a0.e61c38","order":1,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":950,"y":160,"wires":[["c5ad4e90.ec1588"]]},{"id":"ca501565.9b3db","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Patio","group":"f5c472a0.e61c38","order":5,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":950,"y":200,"wires":[["2cce10f8.1804"]]},{"id":"768a07a8.b8754","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Laural ","group":"f5c472a0.e61c38","order":6,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":950,"y":240,"wires":[["4dff637c.b27044"]]},{"id":"f02531b7.9bbfa8","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Office Lights","group":"f5c472a0.e61c38","order":7,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":970,"y":280,"wires":[["65493878.efbe48"]]},{"id":"c5ad4e90.ec1588","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"fence CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1420,"y":160,"wires":[]},{"id":"f1208db4.8606c","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"front CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1418,"y":320,"wires":[]},{"id":"65493878.efbe48","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"office CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1418,"y":280,"wires":[]},{"id":"4dff637c.b27044","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"laural CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1418,"y":240,"wires":[]},{"id":"2cce10f8.1804","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"patio CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1420,"y":200,"wires":[]},{"id":"4da97e8.a031b","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Front Landscaping 2","group":"f5c472a0.e61c38","order":9,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":1000,"y":360,"wires":[["f29d6e7.f37931"]]},{"id":"f29d6e7.f37931","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"front2 CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1418,"y":360,"wires":[]},{"id":"9bb6ea56.e661b8","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Front Landscaping ","group":"f5c472a0.e61c38","order":8,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":990,"y":320,"wires":[["f1208db4.8606c","acc9acac.c0d07"]]},{"id":"7d28a5d2.c7d07c","type":"mqtt in","z":"f72768f0.86b438","name":"","topic":"Radar 1","qos":"0","broker":"1e15ad8.e7e0353","x":70,"y":340,"wires":[["602e3b25.ee67a4"]]},{"id":"acc9acac.c0d07","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"from front","qos":"","retain":"","broker":"1e15ad8.e7e0353","x":1598,"y":320,"wires":[]},{"id":"467bc5b1.ac2b54","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Fountain","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1418,"y":400,"wires":[]},{"id":"f04eecaa.bae388","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Fountain Water","tooltip":"","group":"f5c472a0.e61c38","order":2,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":980,"y":400,"wires":[["467bc5b1.ac2b54"]]},{"id":"e88f825.597fa8","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"All back yard ","tooltip":"","group":"22b71788.1ee79","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":970,"y":460,"wires":[["46acada5.9646cc"]]},{"id":"d5fe992d.5dd8c","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Hedge Light 1","qos":"","retain":"","broker":"2fae8459.4606dc","x":1438,"y":600,"wires":[]},{"id":"46acada5.9646cc","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":480,"wires":[["f58a7e27.120b6","e349fb3f.bb7828","9e0fc9f7.7d6a48","624968c2.b70208"]]},{"id":"f58a7e27.120b6","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":520,"wires":[["e656f736.3ba41","ea0f1338.160898","d457550f.8993b"]]},{"id":"e656f736.3ba41","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":560,"wires":[["fecee1bf.95b058","1c721b93.e1f2bc","46535663.f510b8"]]},{"id":"e511bb35.a240e8","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":720,"wires":[["fd71d7ff.e6964","c172857e.6cfd28"]]},{"id":"fda26e95.bb571","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":800,"wires":[["1700c4df.caf90b","d6f0991.bc80068"]]},{"id":"1700c4df.caf90b","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":840,"wires":[["1cd2df56.115ff1","89f561c2.2fb72"]]},{"id":"c67dd208.2cbf6","type":"ui_switch","z":"f72768f0.86b438","name":"","label":"Water all garden beds","group":"f5c472a0.e61c38","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1000,"y":120,"wires":[["325d622f.9eec36","b33cde6.c248e2","e2cfab0a.8f3f2"]]},{"id":"325d622f.9eec36","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Water 1","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1420,"y":120,"wires":[]},{"id":"b33cde6.c248e2","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Water 2","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1600,"y":120,"wires":[]},{"id":"e2cfab0a.8f3f2","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Water 3","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1800,"y":120,"wires":[]},{"id":"e349fb3f.bb7828","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 1","qos":"","retain":"","broker":"2fae8459.4606dc","x":1430,"y":480,"wires":[]},{"id":"2c25c62a.4ac8da","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Hedge Light 2","qos":"","retain":"","broker":"2fae8459.4606dc","x":1438,"y":640,"wires":[]},{"id":"ea0f1338.160898","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 2","qos":"","retain":"","broker":"2fae8459.4606dc","x":1428,"y":520,"wires":[]},{"id":"682ad6ca.85ab28","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Hedge Light 3","qos":"","retain":"","broker":"2fae8459.4606dc","x":1438,"y":680,"wires":[]},{"id":"fecee1bf.95b058","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 3","qos":"","retain":"","broker":"2fae8459.4606dc","x":1428,"y":560,"wires":[]},{"id":"fd71d7ff.e6964","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Under Closet","qos":"","retain":"","broker":"2fae8459.4606dc","x":1428,"y":720,"wires":[]},{"id":"d066857f.d6b4e","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"patio CP","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1598,"y":800,"wires":[]},{"id":"21510b28.86ebc4","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"laural CP","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1598,"y":840,"wires":[]},{"id":"3fa7639b.5c190c","type":"rpi-gpio in","z":"f72768f0.86b438","name":"Light Sensor","pin":"29","intype":"tri","debounce":"25","read":false,"x":70,"y":580,"wires":[["f2a6d955.b6243"]]},{"id":"1c44f18f.07e29e","type":"ui_chart","z":"f72768f0.86b438","name":"","group":"5a80d96d.843888","order":8,"width":0,"height":0,"label":"Light sensor","chartType":"line","legend":"false","xformat":"dd HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"12","removeOlderPoints":"","removeOlderUnit":"604800","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":2,"x":470,"y":720,"wires":[[],[]],"outputLabels":["dusk_till_dawn",""]},{"id":"f2a6d955.b6243","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"rate","timeout":"10","timeoutUnits":"minutes","rate":"2","nbRateUnits":"10","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":260,"y":580,"wires":[["1c44f18f.07e29e","d198967c.aead3","a380c789.e9924","46acada5.9646cc"]]},{"id":"1cd2df56.115ff1","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":880,"wires":[["e6bceef4.a4328"]]},{"id":"6f98afb.b165dd","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"fence CP","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1598,"y":880,"wires":[]},{"id":"d6f0991.bc80068","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1438,"y":800,"wires":[["d066857f.d6b4e","1745fb62.385625"]]},{"id":"89f561c2.2fb72","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1438,"y":840,"wires":[["21510b28.86ebc4"]]},{"id":"e6bceef4.a4328","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1438,"y":880,"wires":[["6f98afb.b165dd"]]},{"id":"7d9328f0.dcb39","type":"inject","z":"f72768f0.86b438","name":"Turn Off at 10:00 PM","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"00 22 ","once":false,"onceDelay":0.1,"x":500,"y":460,"wires":[["f04eecaa.bae388"]]},{"id":"6cce1600.f60a48","type":"inject","z":"f72768f0.86b438","name":"","topic":"water every day","payload":"1","payloadType":"num","repeat":"","crontab":"30 06 * 1,4","once":false,"onceDelay":0.1,"x":150,"y":120,"wires":[["c67dd208.2cbf6"]]},{"id":"1c721b93.e1f2bc","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":600,"wires":[["814e1038.c12e28","d5fe992d.5dd8c","f9f048ba.809208"]]},{"id":"814e1038.c12e28","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":640,"wires":[["d5db0f97.f602d","2c25c62a.4ac8da","f64d30ab.2eeca"]]},{"id":"d5db0f97.f602d","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":680,"wires":[["e511bb35.a240e8","682ad6ca.85ab28","eb462604.f42f9"]]},{"id":"c172857e.6cfd28","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1248,"y":760,"wires":[["fda26e95.bb571","fa93b53e.441a"]]},{"id":"fa93b53e.441a","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Edge of House","qos":"","retain":"","broker":"2fae8459.4606dc","x":1438,"y":760,"wires":[]},{"id":"d198967c.aead3","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Dusk till Dawn","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":480,"y":760,"wires":[]},{"id":"735f1465.e43b14","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 1 FB1 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1810,"y":480,"wires":[]},{"id":"e039e7d4.3526a","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 2 FB2 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1810,"y":520,"wires":[]},{"id":"45c122bc.c735e4","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 3 FB3 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1810,"y":560,"wires":[]},{"id":"10fd1e7a.531a92","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Front Hedge ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1790,"y":440,"wires":[]},{"id":"79044ed3.75d848","type":"mqtt in","z":"f72768f0.86b438","name":"","topic":"Radar 2","qos":"0","broker":"1e15ad8.e7e0353","x":70,"y":380,"wires":[["602e3b25.ee67a4"]]},{"id":"809f82b6.2bd9c","type":"time-range-switch","z":"f72768f0.86b438","name":"On at 22:00 off at dawn","lat":"45.5051° N","lon":"122.6750° W","startTime":"22:01","endTime":"07:31","startOffset":0,"endOffset":0,"x":510,"y":380,"wires":[["570599d1.265a3"],[]]},{"id":"9e74484b.2d0f9","type":"delay","z":"f72768f0.86b438","name":"On delay ","pauseType":"delay","timeout":"0","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":420,"wires":[["809f82b6.2bd9c"]]},{"id":"602e3b25.ee67a4","type":"switch","z":"f72768f0.86b438","name":"Timing signal change","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":240,"y":380,"wires":[["67eb2222.2bc4dc"],["9e74484b.2d0f9"]]},{"id":"67eb2222.2bc4dc","type":"delay","z":"f72768f0.86b438","name":"Off delay","pauseType":"delay","timeout":"360","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":340,"wires":[["809f82b6.2bd9c"]]},{"id":"570599d1.265a3","type":"change","z":"f72768f0.86b438","name":"My Time out change ","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"str","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":380,"wires":[["63785cd.83621a4","46acada5.9646cc"]]},{"id":"8039d2f8.ea5b18","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"office CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1920,"y":800,"wires":[]},{"id":"1745fb62.385625","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1760,"y":800,"wires":[[]]},{"id":"48b1c1e4.54ede","type":"mqtt in","z":"f72768f0.86b438","name":"","topic":"Radar 3","qos":"0","broker":"1e15ad8.e7e0353","x":70,"y":420,"wires":[["602e3b25.ee67a4"]]},{"id":"9c987ec0.445a4","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Hedge Light 1","qos":"","retain":"","broker":"2fae8459.4606dc","x":1440,"y":1080,"wires":[]},{"id":"8d2cb6b6.17802","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":960,"wires":[["511b2aa6.24d744","5656fb2e.ad9374","2337b1b7.1a0e06","799d0883.a4b9c"]]},{"id":"511b2aa6.24d744","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1000,"wires":[["a120934d.3ce34","cc90ff22.ba5588","ed9c9bd5.e2d658"]]},{"id":"a120934d.3ce34","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1040,"wires":[["cf16c0d0.00c85","39cd35c6.1333aa","eee3386a.9714e8"]]},{"id":"2547e0b0.52f3","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1250,"y":1200,"wires":[["bf54ebb8.b049e8","58e1fcb4.c10454"]]},{"id":"176f10.011350f1","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1280,"wires":[["3096c5f5.fa1d52","e01433da.8524"]]},{"id":"3096c5f5.fa1d52","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1320,"wires":[["55a3f780.1ee2d","9aecd804.2078"]]},{"id":"5656fb2e.ad9374","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 1","qos":"","retain":"","broker":"2fae8459.4606dc","x":1430,"y":960,"wires":[]},{"id":"fe0497c0.b37d9","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Hedge Light 2","qos":"","retain":"","broker":"2fae8459.4606dc","x":1440,"y":1120,"wires":[]},{"id":"cc90ff22.ba5588","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 2","qos":"","retain":"","broker":"2fae8459.4606dc","x":1430,"y":1000,"wires":[]},{"id":"fce723c.de616e","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Hedge Light 3","qos":"","retain":"","broker":"2fae8459.4606dc","x":1440,"y":1160,"wires":[]},{"id":"cf16c0d0.00c85","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 3","qos":"","retain":"","broker":"2fae8459.4606dc","x":1430,"y":1040,"wires":[]},{"id":"bf54ebb8.b049e8","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Under Closet","qos":"","retain":"","broker":"2fae8459.4606dc","x":1430,"y":1200,"wires":[]},{"id":"87f9fda2.2a8e78","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"patio CP","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1960,"y":1260,"wires":[]},{"id":"abe7d97d.6881b","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"laural CP","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1600,"y":1320,"wires":[]},{"id":"55a3f780.1ee2d","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1360,"wires":[["c7e8037d.eb06e8"]]},{"id":"6ba62f32.4f279","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"fence CP","qos":"","retain":"","broker":"4d88f4fd.edbb24","x":1600,"y":1360,"wires":[]},{"id":"e01433da.8524","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"1","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1440,"y":1280,"wires":[["91e5f6b4.18c4"]]},{"id":"9aecd804.2078","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1440,"y":1320,"wires":[["abe7d97d.6881b"]]},{"id":"c7e8037d.eb06e8","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1440,"y":1360,"wires":[["6ba62f32.4f279"]]},{"id":"39cd35c6.1333aa","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1080,"wires":[["9d2816e2.f1ce68","9c987ec0.445a4","1ed6e3d3.01ad3c"]]},{"id":"9d2816e2.f1ce68","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":".1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":1120,"wires":[["84575fa1.703d3","fe0497c0.b37d9","481ae4e6.be749c"]]},{"id":"84575fa1.703d3","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1250,"y":1160,"wires":[["2547e0b0.52f3","fce723c.de616e","96094061.deaa68"]]},{"id":"58e1fcb4.c10454","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1250,"y":1240,"wires":[["176f10.011350f1","54ac1de.7f18c64"]]},{"id":"54ac1de.7f18c64","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Edge of House","qos":"","retain":"","broker":"2fae8459.4606dc","x":1440,"y":1240,"wires":[]},{"id":"2337b1b7.1a0e06","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 1 FB1 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1632,"y":960,"wires":[]},{"id":"ed9c9bd5.e2d658","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 2 FB2 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1632,"y":1000,"wires":[]},{"id":"eee3386a.9714e8","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Down Light 3 FB3 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1632,"y":1040,"wires":[]},{"id":"1ed6e3d3.01ad3c","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Back Light 1 FB1 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1632,"y":1080,"wires":[]},{"id":"481ae4e6.be749c","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Back Light 2 FB2 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1632,"y":1120,"wires":[]},{"id":"96094061.deaa68","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Back Light 3 FB3 ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1632,"y":1160,"wires":[]},{"id":"799d0883.a4b9c","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"Front Hedge ","qos":"","retain":"","broker":"2fae8459.4606dc","x":1812,"y":960,"wires":[]},{"id":"13c08e33.73c982","type":"mqtt out","z":"f72768f0.86b438","name":"","topic":"office CP","qos":"0","retain":"","broker":"1e15ad8.e7e0353","x":1960,"y":1300,"wires":[]},{"id":"dabfbb95.5cd298","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1820,"y":1320,"wires":[["13c08e33.73c982"]]},{"id":"21cfabff.309aac","type":"mqtt in","z":"f72768f0.86b438","name":"","topic":"Radar 1","qos":"0","broker":"1e15ad8.e7e0353","x":90,"y":920,"wires":[["62c3b539.820a14"]]},{"id":"8ce6f73b.f0cb4","type":"mqtt in","z":"f72768f0.86b438","name":"","topic":"Radar 2","qos":"0","broker":"1e15ad8.e7e0353","x":90,"y":960,"wires":[["62c3b539.820a14"]]},{"id":"7f9c9085.525bc","type":"delay","z":"f72768f0.86b438","name":"On delay ","pauseType":"delay","timeout":"0","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":1000,"wires":[["58890b30.4abec4"]]},{"id":"62c3b539.820a14","type":"switch","z":"f72768f0.86b438","name":"Timing signal change","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":960,"wires":[["a4b9919c.f6dc8"],["7f9c9085.525bc"]]},{"id":"a4b9919c.f6dc8","type":"delay","z":"f72768f0.86b438","name":"Off delay","pauseType":"delay","timeout":"360","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":380,"y":920,"wires":[["58890b30.4abec4"]]},{"id":"38fa3d08.af80f2","type":"change","z":"f72768f0.86b438","name":"My Time out change ","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"str","to":"0","tot":"num"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"str","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":880,"wires":[[]]},{"id":"8315a546.2a0788","type":"mqtt in","z":"f72768f0.86b438","name":"","topic":"Radar 3","qos":"0","broker":"1e15ad8.e7e0353","x":90,"y":1000,"wires":[["62c3b539.820a14"]]},{"id":"a380c789.e9924","type":"switch","z":"f72768f0.86b438","name":"Timing signal change","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":500,"wires":[["f04eecaa.bae388"],[]]},{"id":"a9547f0f.e1ff4","type":"delay","z":"f72768f0.86b438","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1820,"y":1240,"wires":[["87f9fda2.2a8e78"]]},{"id":"60ee2a66.fbedb4","type":"inject","z":"f72768f0.86b438","name":"Lights off","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"30 19 *","once":false,"onceDelay":0.1,"x":950,"y":1040,"wires":[["8d2cb6b6.17802"]]},{"id":"b43f54cd.fbe038","type":"inject","z":"f72768f0.86b438","name":"Lights ON","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":940,"y":1080,"wires":[["8d2cb6b6.17802","58890b30.4abec4"]]},{"id":"91e5f6b4.18c4","type":"switch","z":"f72768f0.86b438","name":"Timing signal change","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"false","vt":"msg"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1640,"y":1280,"wires":[["87f9fda2.2a8e78","13c08e33.73c982"],["dabfbb95.5cd298","a9547f0f.e1ff4"]]},{"id":"fe4adc91.d5fe8","type":"inject","z":"f72768f0.86b438","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":790,"y":480,"wires":[["e88f825.597fa8"]]},{"id":"9e0fc9f7.7d6a48","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":440,"wires":[["10fd1e7a.531a92"]]},{"id":"624968c2.b70208","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":480,"wires":[["735f1465.e43b14"]]},{"id":"d457550f.8993b","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":520,"wires":[["e039e7d4.3526a"]]},{"id":"46535663.f510b8","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":560,"wires":[["45c122bc.c735e4"]]},{"id":"f9f048ba.809208","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":600,"wires":[[]]},{"id":"f64d30ab.2eeca","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":640,"wires":[[]]},{"id":"eb462604.f42f9","type":"change","z":"f72768f0.86b438","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"true","tot":"bool"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":680,"wires":[[]]},{"id":"58890b30.4abec4","type":"time-range-switch","z":"f72768f0.86b438","name":"On at 22:00 off at dawn","lat":"45.5051° N","lon":"122.6750° W","startTime":"10:42","endTime":"dawn","startOffset":0,"endOffset":0,"x":570,"y":960,"wires":[["bb2da155.80d928"],["cd08db17.0dda5"]]},{"id":"cd08db17.0dda5","type":"debug","z":"f72768f0.86b438","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":740,"y":1040,"wires":[]},{"id":"bb2da155.80d928","type":"debug","z":"f72768f0.86b438","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":820,"wires":[]},{"id":"63785cd.83621a4","type":"debug","z":"f72768f0.86b438","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":780,"y":320,"wires":[]},{"id":"f5c472a0.e61c38","type":"ui_group","z":"","name":"Light Controls ","tab":"5b23795f.7b0fb8","order":1,"disp":true,"width":"6","collapse":false},{"id":"1e15ad8.e7e0353","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.50","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"4d88f4fd.edbb24","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.50","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"22b71788.1ee79","type":"ui_group","z":"","name":"Exterior Lights","tab":"5b23795f.7b0fb8","order":2,"disp":true,"width":"6","collapse":false},{"id":"2fae8459.4606dc","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.50","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"5a80d96d.843888","type":"ui_group","z":"","name":"","tab":"a97c7158.4162b","disp":true,"width":"13","collapse":false},{"id":"5b23795f.7b0fb8","type":"ui_tab","z":"","name":"Light Control ","icon":"dashboard","order":1},{"id":"a97c7158.4162b","type":"ui_tab","z":"","name":"Garage Fridge","icon":"dashboard"}]

Poodlepapa commented 5 years ago

FYI I've been doing a lot of testing and messing around so that flow is not very tidy. the upper version of the time range node seems to be working now but ill need to wait until dark to really tell. its weird, I can alter the time so I can test it and it all works but it seems to fail at night and I'm not exactly sure why. I made some changes today that might have fixed it. the time range node on the bottom is just weird and has never worked. Thank you very much in advance, any other suggestions you might have or glaring errors you see please feel free to let me know. Im self taught and have no idea what best practices i should be using. Thanks!

Also- my end goal is to have the landscaping lights turn on via MQTT signal at dusk THEN turn off at 10:00 THEN turn on when motion is detected until dawn. Seems easy, its not!

biddster commented 5 years ago

What you want should be easy. It's pretty much the setup my dad has with his stair lights. He uses schedex and time-range-switch to do more or less the same as what you want.

I'll check out your flow.

biddster commented 4 years ago

@Poodlepapa , sorry for being so slow on this one, but here is how I've done what you want at home.

Motion is received via cheapo 433mhz sensors. I use time range switch to drop messages unless they're between midnight and sunrise. If we're within that window, I set the payload to 'on' and that connects to node-red-contrib-timeouttrigger. This trigger allows the 'on' message through and sends 'off' if no messages are received within 10 mins. I wire that into Schedex which deals with routine daily scheduling for 'on' and 'off'. Out of shot is the mqtt send node for turning on the light.

Screenshot 2020-01-16 at 21 12 04
matteos1 commented 4 years ago

also for me sun event give problem

RogerSelwyn commented 1 year ago

Mine is showing sunrise and sunset incorrect by two hours, and I'm in utc, so not that. Besides one is 2 hours late, the other two hours early.