Hello floks,
I discoverd node red a week ago and it's seems perfect for my home control dream with my low programation knowledge...
I'm trying to control a gpio from my raspberry to start and stop at a certain time I select in the dashboard (time picker)
My code is not pretty but it's kinda working...I just cannot succed to compare the actual time with my inputs.
The problem is for me in the "in time?" function node
Two days in, I'm lossing my mind, HELP!
[{"id":"b8b61556.49e7d8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"b71d6cc.4e7329","type":"schedex","z":"b8b61556.49e7d8","name":"lamp controle","suspended":true,"lat":"","lon":"","ontime":"","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":900,"y":240,"wires":[["c8a83827.bf0f78","63d075cc.a7b9cc"]]},{"id":"93d7789e.07b5b8","type":"debug","z":"b8b61556.49e7d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":870,"y":200,"wires":[]},{"id":"f29d19ce.b31a48","type":"ui_text_input","z":"b8b61556.49e7d8","name":"","label":"Stop time","tooltip":"","group":"841f7e06.0ded2","order":7,"width":"3","height":"1","passthru":true,"mode":"time","delay":300,"topic":"","x":100,"y":280,"wires":[["55153aa0.682414"]]},{"id":"23c81448.09b38c","type":"ui_text_input","z":"b8b61556.49e7d8","name":"","label":"Go time","tooltip":"","group":"841f7e06.0ded2","order":6,"width":"3","height":"1","passthru":true,"mode":"time","delay":300,"topic":"","x":80,"y":240,"wires":[["510fa072.b6068"]]},{"id":"510fa072.b6068","type":"function","z":"b8b61556.49e7d8","name":"format time","func":"msg.play = parseFloat(msg.payload/1000);\n\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":240,"wires":[["13b18663.1228ba","9ddeee45.7ad7d"]]},{"id":"55153aa0.682414","type":"function","z":"b8b61556.49e7d8","name":"format time","func":"msg.stop = parseFloat(msg.payload/1000);\n\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":280,"wires":[["13b18663.1228ba","9ddeee45.7ad7d"]]},{"id":"13b18663.1228ba","type":"function","z":"b8b61556.49e7d8","name":"in time?","func":"var timeOn = msg.play;\nvar timeOff = msg.stop;\nvar timeNow = msg.time;\n\n if(timeNow>=timeOn && timeNow<=timeOff)\n\t\t{\n\t\t\t msg.payload = 'on';\n\t\t}\n else\n {\n\t\t\tmsg.payload = 'off';\n\t\t}\n \n\t\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":240,"wires":[["b71d6cc.4e7329","93d7789e.07b5b8"]]},{"id":"14789a0a.dae326","type":"inject","z":"b8b61556.49e7d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":80,"y":320,"wires":[["814d1cab.34185"]]},{"id":"a44c7ba9.311188","type":"moment","z":"b8b61556.49e7d8","name":"seconds","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Brussels","adjAmount":0,"adjType":"days","adjDir":"add","format":"ss","locale":"fr_BE","output":"second","outputType":"msg","outTz":"Europe/Brussels","x":240,"y":400,"wires":[["7a5c378b.29edc8"]]},{"id":"7177f4a4.9845ac","type":"moment","z":"b8b61556.49e7d8","name":"minutes","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Brussels","adjAmount":0,"adjType":"days","adjDir":"add","format":"mm","locale":"fr_BE","output":"minute","outputType":"msg","outTz":"Europe/Brussels","x":240,"y":360,"wires":[["a44c7ba9.311188"]]},{"id":"814d1cab.34185","type":"moment","z":"b8b61556.49e7d8","name":"hours","topic":"","input":"payload","inputType":"msg","inTz":"Europe/Brussels","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH","locale":"fr_BE","output":"hour","outputType":"msg","outTz":"Europe/Brussels","x":230,"y":320,"wires":[["7177f4a4.9845ac"]]},{"id":"6e2ec02e.4b667","type":"function","z":"b8b61556.49e7d8","name":"m","func":"msg.minute = parseFloat(msg.minute*60);\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":360,"wires":[["3d329590.722a9a"]]},{"id":"7a5c378b.29edc8","type":"function","z":"b8b61556.49e7d8","name":"h","func":"msg.hour = parseFloat(msg.hour*3600);\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":320,"wires":[["6e2ec02e.4b667"]]},{"id":"3d329590.722a9a","type":"function","z":"b8b61556.49e7d8","name":"s","func":"msg.second = parseFloat(msg.second);\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":400,"wires":[["e64c5706.085fa8"]]},{"id":"e64c5706.085fa8","type":"function","z":"b8b61556.49e7d8","name":"sum","func":"msg.time = msg.second+msg.minute+msg.hour;\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":400,"wires":[["13b18663.1228ba","f69f47cc.7dcc58"]]},{"id":"c8a83827.bf0f78","type":"debug","z":"b8b61556.49e7d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1110,"y":280,"wires":[]},{"id":"63d075cc.a7b9cc","type":"rpi-gpio out","z":"b8b61556.49e7d8","name":"","pin":"32","set":"","level":"0","freq":"","out":"out","x":1120,"y":240,"wires":[]},{"id":"9ddeee45.7ad7d","type":"debug","z":"b8b61556.49e7d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":690,"y":200,"wires":[]},{"id":"f69f47cc.7dcc58","type":"debug","z":"b8b61556.49e7d8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":690,"y":400,"wires":[]},{"id":"841f7e06.0ded2","type":"ui_group","z":"","name":"Croissance","tab":"2fb138d2.a45978","order":2,"disp":true,"width":"6","collapse":false},{"id":"2fb138d2.a45978","type":"ui_tab","z":"","name":"Photopériode","icon":"dashboard","order":3,"disabled":false,"hidden":false}]
Thanks