2019年11月24日 星期日

Node-RED 一定時間後輸出到payload

一定時間後輸出到payload。

源自於  https://cafe.naver.com/nodered



[{"id":"ca69abf0.22ce88","type":"trigger","z":"ad5297e5.94bf08","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"1","extend":false,"units":"s","reset":"0","bytopic":"all","name":"","x":340,"y":320,"wires":[["8853a0f2.c91cd"]]},{"id":"a218d017.29eeb","type":"inject","z":"ad5297e5.94bf08","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":156.99995613098145,"y":265.9999580383301,"wires":[["8853a0f2.c91cd"]]},{"id":"5363b076.d29b8","type":"inject","z":"ad5297e5.94bf08","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":154.99995613098145,"y":316.9999580383301,"wires":[["8853a0f2.c91cd"]]},{"id":"8853a0f2.c91cd","type":"function","z":"ad5297e5.94bf08","name":"after 5","func":"var input = msg.payload;\nvar count = context.get('count')||0;\nvar msg1 ={};\ncount = count + input;\ncontext.set('count',count);\n\nif(input == '0') {\n    context.set('count',0);\n    msg.payload = 0;\n    msg1.payload = 0;\n    return [msg,msg1];\n}else{\n    if(count > '5') {       // after 5 second\n        msg.payload = 1;\n        msg1.payload = 1;\n        return [msg,msg1];\n    }else{\n        msg.payload = 1;\n        return msg;\n    }\n}\n\n\n","outputs":2,"noerr":0,"x":332,"y":266,"wires":[["ca69abf0.22ce88"],["52818114.1176d"]]},{"id":"52818114.1176d","type":"debug","z":"ad5297e5.94bf08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":514.0000629425049,"y":270.00000858306885,"wires":[]},{"id":"18425f86.07e3d","type":"comment","z":"ad5297e5.94bf08","name":"after 5","info":"","x":130.99995613098145,"y":78.99991703033447,"wires":[]},{"id":"e5c4635e.296cf","type":"delay","z":"ad5297e5.94bf08","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":459.0796146392822,"y":140.11798191070557,"wires":[["ae91587.0fd5ea8"]]},{"id":"2c204da4.1ffeb2","type":"function","z":"ad5297e5.94bf08","name":"after 5","func":"var msg1={};\n\nif(msg.payload == '0'){\n    msg.reset = true;       //delay reset\n    msg1.payload = 0;\n    return [msg,msg1];    \n}else{\n    return msg;\n}","outputs":2,"noerr":0,"x":311.07295417785645,"y":180.3089702129364,"wires":[["e5c4635e.296cf"],["ae91587.0fd5ea8"]]},{"id":"ae91587.0fd5ea8","type":"debug","z":"ad5297e5.94bf08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":621.0728778839111,"y":186.60067653656006,"wires":[]},{"id":"b6072921.e6bd98","type":"inject","z":"ad5297e5.94bf08","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":155.01729774475098,"y":141.01033687591553,"wires":[["2c204da4.1ffeb2"]]},{"id":"6e58575.10e98a8","type":"inject","z":"ad5297e5.94bf08","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":154.01729011535645,"y":180.01033210754395,"wires":[["2c204da4.1ffeb2"]]}]

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...