Hi, I'm trying to create like a timer from the dashabord so the user select the hout to start, and I'm having troubles to create the object.
I will paste my flow here.
[{"id":"78b0667e.628df8","type":"tab","label":"Irrigation"},{"id":"15216bf0.bba004","type":"ui_text","z":"78b0667e.628df8","group":"6fc0ea2b.f44424","order":2,"width":"","height":"","name":"Time:","label":"Time:","format":"{{msg.payload}}","layout":"","x":890,"y":60,"wires":[]},{"id":"b9441f07.5579f","type":"function","z":"78b0667e.628df8","name":"Calculate time","func":"global.set(msg.topic,msg.payload);\nvar hour = global.get(\"timehour\");\nvar minute = global.get(\"timeminute\");\nif (hour!==undefined && minute!==undefined) {\n var mytime = new Date();\n mytime.setHours(hour, minute, 0);\n mytime.setMilliseconds(0);\n mytime.setFullYear(2000,01,01);\n global.set(\"start\",mytime.getTime());\n}\nmsg.payload = hour + \":\" + minute;\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":120,"wires":[["15216bf0.bba004","485f187.da492e8","537737cb.cd9498"]]},{"id":"ad54459c.f90628","type":"comment","z":"78b0667e.628df8","name":"Convert the slider values to time","info":"","x":598,"y":37,"wires":[]},{"id":"eb93e76f.752f38","type":"ui_button","z":"78b0667e.628df8","name":"Start now","group":"33827a4a.b278f6","order":5,"width":"","height":"","label":"In 1 minute","color":"","icon":"","payload":"now","payloadType":"str","topic":"","x":76,"y":113,"wires":[["99795154.eed4c","9cc47814.f98f68"]]},{"id":"ec239b55.dc1258","type":"ui_button","z":"78b0667e.628df8","name":"Start dawn","group":"33827a4a.b278f6","order":6,"width":"","height":"","label":"4am in the morning","color":"","icon":"","payload":"dawn","payloadType":"str","topic":"","x":77,"y":153,"wires":[["3ccb2411.a67dfc","ff64bd8.384264"]]},{"id":"d89901be.7a63c","type":"comment","z":"78b0667e.628df8","name":"Preset times","info":"","x":84,"y":29,"wires":[]},{"id":"3ccb2411.a67dfc","type":"change","z":"78b0667e.628df8","name":"Dawn hour","rules":[{"t":"set","p":"payload","pt":"msg","to":"4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":129,"wires":[["da58f1e7.9df5a"]]},{"id":"ff64bd8.384264","type":"change","z":"78b0667e.628df8","name":"Dawn minute","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":319,"y":171,"wires":[["b8a5a3b9.ffad"]]},{"id":"99795154.eed4c","type":"function","z":"78b0667e.628df8","name":"Now hour","func":"var mydate = new Date();\nmsg.payload = mydate.getHours();\nreturn msg;","outputs":1,"noerr":0,"x":312,"y":35,"wires":[["da58f1e7.9df5a"]]},{"id":"9cc47814.f98f68","type":"function","z":"78b0667e.628df8","name":"Now minute","func":"var mydate = new Date();\nmydate.setTime(mydate.getTime() + 1*60000);\nmsg.payload = mydate.getMinutes();\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":79,"wires":[["b8a5a3b9.ffad"]]},{"id":"96c34d86.effcd","type":"inject","z":"78b0667e.628df8","name":"","repeat":"","crontab":"","once":false,"topic":"","payload":"start","payloadType":"global","x":742,"y":203,"wires":[["ee39bb48.9680d8"]]},{"id":"ee39bb48.9680d8","type":"debug","z":"78b0667e.628df8","name":"","active":true,"console":"false","complete":"false","x":899,"y":204,"wires":[]},{"id":"da58f1e7.9df5a","type":"ui_dropdown","z":"78b0667e.628df8","name":"Hour","label":"Hour","group":"6fc0ea2b.f44424","order":3,"width":0,"height":0,"passthru":true,"options":[{"label":"00","value":"0","type":"str"},{"label":"01","value":"1","type":"str"},{"label":"02","value":"2","type":"str"},{"label":"03","value":"3","type":"str"},{"label":"04","value":"4","type":"str"},{"label":"05","value":"5","type":"str"},{"label":"06","value":"6","type":"str"},{"label":"07","value":"7","type":"str"},{"label":"08","value":"8","type":"str"},{"label":"09","value":"9","type":"str"},{"label":"10","value":"10","type":"str"},{"label":"11","value":"11","type":"str"},{"label":"12","value":"12","type":"str"},{"label":"13","value":"13","type":"str"},{"label":"14","value":"14","type":"str"},{"label":"15","value":"15","type":"str"},{"label":"16","value":"16","type":"str"},{"label":"17","value":"17","type":"str"},{"label":"18","value":"18","type":"str"},{"label":"19","value":"19","type":"str"},{"label":"20","value":"20","type":"str"},{"label":"21","value":"21","type":"str"},{"label":"22","value":"22","type":"str"},{"label":"23","value":"23","type":"str"}],"payload":"","topic":"timehour","x":519,"y":92,"wires":[["b9441f07.5579f"]]},{"id":"b8a5a3b9.ffad","type":"ui_dropdown","z":"78b0667e.628df8","name":"Minute","label":"Minute","group":"6fc0ea2b.f44424","order":4,"width":0,"height":0,"passthru":true,"options":[{"label":"00","value":"0","type":"str"},{"label":"01","value":"1","type":"str"},{"label":"02","value":"2","type":"str"},{"label":"03","value":"3","type":"str"},{"label":"04","value":"4","type":"str"},{"label":"05","value":"5","type":"str"},{"label":"06","value":"6","type":"str"},{"label":"07","value":"7","type":"str"},{"label":"08","value":"8","type":"str"},{"label":"09","value":"9","type":"str"},{"label":"10","value":"10","type":"str"},{"label":"11","value":"11","type":"str"},{"label":"12","value":"12","type":"str"},{"label":"13","value":"13","type":"str"},{"label":"14","value":"14","type":"str"},{"label":"15","value":"15","type":"str"},{"label":"16","value":"16","type":"str"},{"label":"17","value":"17","type":"str"},{"label":"18","value":"18","type":"str"},{"label":"19","value":"19","type":"str"},{"label":"20","value":"20","type":"str"},{"label":"21","value":"21","type":"str"},{"label":"22","value":"22","type":"str"},{"label":"23","value":"23","type":"str"},{"label":"24","value":"24","type":"str"},{"label":"25","value":"25","type":"str"},{"label":"26","value":"26","type":"str"},{"label":"27","value":"27","type":"str"},{"label":"28","value":"28","type":"str"},{"label":"29","value":"29","type":"str"},{"label":"30","value":"30","type":"str"},{"label":"31","value":"31","type":"str"},{"label":"32","value":"32","type":"str"},{"label":"33","value":"33","type":"str"},{"label":"34","value":"34","type":"str"},{"label":"35","value":"35","type":"str"},{"label":"36","value":"36","type":"str"},{"label":"37","value":"37","type":"str"},{"label":"38","value":"38","type":"str"},{"label":"39","value":"39","type":"str"},{"label":"40","value":"40","type":"str"},{"label":"41","value":"41","type":"str"},{"label":"42","value":"42","type":"str"},{"label":"43","value":"43","type":"str"},{"label":"44","value":"44","type":"str"},{"label":"45","value":"45","type":"str"},{"label":"46","value":"46","type":"str"},{"label":"47","value":"47","type":"str"},{"label":"48","value":"48","type":"str"},{"label":"49","value":"49","type":"str"},{"label":"50","value":"50","type":"str"},{"label":"51","value":"51","type":"str"},{"label":"52","value":"52","type":"str"},{"label":"53","value":"53","type":"str"},{"label":"54","value":"54","type":"str"},{"label":"55","value":"55","type":"str"},{"label":"56","value":"56","type":"str"},{"label":"57","value":"57","type":"str"},{"label":"58","value":"58","type":"str"},{"label":"59","value":"59","type":"str"}],"payload":"","topic":"timeminute","x":518,"y":135,"wires":[["b9441f07.5579f"]]},{"id":"18d15af5.3fa295","type":"ui_dropdown","z":"78b0667e.628df8","name":"Irrigate in days","label":"Irrigate in","group":"6fc0ea2b.f44424","order":5,"width":0,"height":0,"passthru":false,"options":[{"label":"Every day","value":1,"type":"num"},{"label":"Every second day","value":"2","type":"str"},{"label":"Every third day","value":"3","type":"str"},{"label":"Every forth day","value":"4","type":"str"}],"payload":"","topic":"irrdays","x":115,"y":272,"wires":[["44706bb0.fd37c4"]]},{"id":"d1084ee3.28c6d","type":"function","z":"78b0667e.628df8","name":"Date logic","func":"var today = new Date();\nif (global.get(\"irrenable\")==1) {\n msg.payload = (today.getDay() % global.get(\"irrdays\") === 0) ? '1':'0';\n} else {\n msg.payload = '0';\n} \nreturn msg;","outputs":1,"noerr":0,"x":612,"y":272,"wires":[["bf1ed4ed.d02968"]]},{"id":"bf1ed4ed.d02968","type":"ui_template","z":"78b0667e.628df8","group":"6fc0ea2b.f44424","name":"Execute today?","order":6,"width":"","height":"","format":"<div layout=\"row\" layout-align=\"space-between\">\n <p>Run today</p>\n <p ng-style=\"{color: msg.payload === '1' ? 'green' : 'red'}\">\n <b>{{(msg.payload === '1') ? 'Yes' : 'No'}}</b>\n </p>\n</div>","storeOutMessages":false,"fwdInMessages":false,"x":834,"y":272,"wires":[[]]},{"id":"9ba68692.8bdc18","type":"ui_switch","z":"78b0667e.628df8","name":"Enabler","label":"Enable Irrigation","group":"6fc0ea2b.f44424","order":1,"width":0,"height":0,"passthru":true,"topic":"irrenable","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":97,"y":223,"wires":[["7f67717.006b19"]]},{"id":"7f67717.006b19","type":"function","z":"78b0667e.628df8","name":"Store","func":"global.set(msg.topic,msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":248,"y":223,"wires":[["d1084ee3.28c6d"]]},{"id":"44706bb0.fd37c4","type":"function","z":"78b0667e.628df8","name":"Store","func":"global.set(msg.topic,msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":288,"y":272,"wires":[["d1084ee3.28c6d"]]},{"id":"537737cb.cd9498","type":"debug","z":"78b0667e.628df8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1010,"y":160,"wires":[]},{"id":"1bb9da23.bfdc26","type":"function","z":"78b0667e.628df8","name":"check command","func":"const time = new Date(msg.payload);\nconst hour = time.getHours();\nconst minute = time.getMinutes();\nlet timef = \"\";\nif(minute<10){\n if(hour>9){\n timef = String(hour) + \":0\" + String(minute);\n } else {\n timef = \"0\"+ String(hour) + \":0\" + String(minute);\n }\n} else {\n if(hour>9){\n timef = String(hour) + \":\" + String(minute);\n } else {\n timef = \"0\"+ String(hour) + \":\" + String(minute);\n }\n}\nconst msgOut = flow.get(\"timetostart\") || [];\nmsgOut.forEach(element => {\n if(element.time == timef) node.send({payload:element.command,item:element.item});\n});\nnode.done();\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":600,"wires":[["80e9179a.5a8208","8c7a9c0.1e4f768"]]},{"id":"57bd5e3f.8f72","type":"inject","z":"78b0667e.628df8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":600,"wires":[["1bb9da23.bfdc26"]]},{"id":"80e9179a.5a8208","type":"debug","z":"78b0667e.628df8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":660,"wires":[]},{"id":"8c7a9c0.1e4f768","type":"function","z":"78b0667e.628df8","name":"","func":"var comandosvalvula=msg.payload;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":600,"wires":[["7c21fde8.a1edb4","5a814fab.2e4bd"]]},{"id":"7c21fde8.a1edb4","type":"mqtt out","z":"78b0667e.628df8","name":"","topic":"lab/valvula","qos":"","retain":"","broker":"f4bed461.43bd28","x":810,"y":600,"wires":[]},{"id":"f3e4930e.1215d","type":"ui_toast","z":"78b0667e.628df8","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"topic":"","name":"","x":950,"y":660,"wires":[]},{"id":"5a814fab.2e4bd","type":"function","z":"78b0667e.628df8","name":"","func":"var comando = msg.payload;\n\n if (comand == \"on\") \n\t {\n\t\tsetTimeout(function(){\n msg.payload = \"is on\";\n node.send(msg);\n }, 9000); // This is how many milliseconds to wait.\n msg.payload = \"turning on\";\n return msg;\n\t} else if (comando == \"off\") \n\t {\n\t\tsetTimeout(function(){\n msg.payload = \"is off\";\n node.send(msg);\n }, 9000); // This is how many milliseconds to wait.\n msg.payload = \"turning off\";\n return msg;\n\t}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":780,"y":660,"wires":[["f3e4930e.1215d"]]},{"id":"9d6bba68.7ef918","type":"debug","z":"78b0667e.628df8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1130,"y":120,"wires":[]},{"id":"485f187.da492e8","type":"function","z":"78b0667e.628df8","name":"","func":"var setstart = msg.payload;\nflow.set(\"setstart\", setstart);\nmsg.payload = setstart;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":120,"wires":[["9d6bba68.7ef918"]]},{"id":"eeafeaee.952bf8","type":"inject","z":"78b0667e.628df8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":420,"wires":[["537a5c65.51a384"]]},{"id":"8f8708cb.cb4608","type":"debug","z":"78b0667e.628df8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":420,"wires":[]},{"id":"537a5c65.51a384","type":"function","z":"78b0667e.628df8","name":"","func":"var timeset = (global.get(\"setstart\"));\n//var t = dateTime.getTime();\npayload={\"time\":timeset,\"command\":\"on\",\"item\":\"lights\"};\nflow.set(\"timetostart\", payload);\nmsg.payload=payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":420,"wires":[["8f8708cb.cb4608"]]},{"id":"6fc0ea2b.f44424","type":"ui_group","z":"","name":"Start Time","tab":"2fe23682.543e8a","order":1,"disp":true,"width":"6"},{"id":"33827a4a.b278f6","type":"ui_group","z":"","name":"Preset Start Times","tab":"2fe23682.543e8a","order":2,"disp":true,"width":"6"},{"id":"f4bed461.43bd28","type":"mqtt-broker","z":"","name":"","broker":"192.168.43.47","port":"1883","clientid":"Hidro","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"2fe23682.543e8a","type":"ui_tab","z":"","name":"Irrigation","icon":"call_split","order":2}]
So this is the function that I'm using.
Here i'm recovering from the context the hour values that would be like this
timeminute : msg.payload : string[3]
"3:4"
var timeset = (global.get("setstart"));
//var t = dateTime.getTime();
payload={"time":timeset,"command":"on","item":"lights"};
flow.set("timetostart", payload);
msg.payload=payload;
return msg;
but creating the object the time never appears I want to have an object like this...