Inching in NodeRED

enter image description here I needed a simple flow for inching mechanism. If you don't know what "inching" means, it's a fancy term for turning a thing ON and then turning it OFF a couple of seconds/minutes later. You could call it a timer wannabee with a preset timer.

Features:

  • Custom timout
  • Single payload message
  • cancel/repeat behaviour

Requirements

  • node-red-dashboard (optional)

Settings

  • timeout - time in seconds to take the opposite action

More about me:

If you want to get the latest updates to this project you can follow me via your preferred social media:

And if you feeling like buying me a coffee or supporting me in a more continuous way:

I hope you have enjoyed the project!

[{"id":"769faa02.df8de4","type":"tab","label":"Inching in NodeRED","disabled":false,"info":"\n![enter image description here](https://notenoughtech.com/wp-content/uploads/2020/04/YouTube-Thumb-6.jpg)\nI needed a simple flow for inching mechanism. If you don't know what \"inching\" means, it's a fancy term for turning a thing ON and then turning it OFF a couple of seconds/minutes later. You could call it a timer wannabee with a preset timer.\n\n - [Complete instructions](https://notenoughtech.com/home-automation/nodered-home-automation/inching)\n\n**Features**:\n-    Custom timout\n-    Single payload message\n-    cancel/repeat behaviour\n\n## Requirements\n\n - node-red-dashboard  (optional)\n\n# Settings\n\n - **timeout** - time in seconds to take the opposite action\n \n ## More about me:\n\nIf you want to get the latest updates to this project you can follow me via your preferred social media:\n\n-   [Facebook](https://www.facebook.com/NotEnoughTECH/)\n-   [Twitter](https://twitter.com/NotEnoughTECH)\n-   [Instagram](https://www.instagram.com/notenoughtech/)\n-   [YouTube](https://www.youtube.com/user/Polepositionpage)\n\nAnd if you feeling like buying me a coffee or supporting me in a more continuous way:\n\n-   [Paypal](https://www.paypal.me/notenoughtech)\n-   [Patreon](https://www.patreon.com/NotEnoughTECH)\n\nI hope you have enjoyed the project!\n\n "},{"id":"958deeae.86b9e","type":"inject","z":"769faa02.df8de4","name":"SET THIS IN SECONDS","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":230,"y":140,"wires":[["5ba08215.8a2f0c"]]},{"id":"5ba08215.8a2f0c","type":"function","z":"769faa02.df8de4","name":"set timeout","func":"flow.set(\"timeout\", msg.payload);\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":140,"wires":[[]]},{"id":"81e9734d.cdef2","type":"function","z":"769faa02.df8de4","name":"inching","func":"var button = msg.payload;\nvar topic = msg.topic;\nvar alarm = context.get(\"alarmState\");\nvar timeout = (flow.get(\"timeout\")) *1000;\n\n// delayed payload\nfunction inching(){\n    let alarm1 = context.get(\"alarmState\");\n    if(alarm1 === true){\n        msg = {payload: false};\n        context.set(\"alarmState\", false);\n        msg1 = {payload: false, topic: \"inching\"};\n        node.send([msg, msg1]);\n    }\n}\n\nif(topic !== \"inching\"){\n// alarm not set\n    if(alarm === false){\n        if(button === true){\n            context.set(\"alarmState\", true);\n            setTimeout(inching, timeout);\n            return [msg, null];\n        }\n        if(button === false){\n            return[msg, null];\n        }\n    }\n//alarm set    \n    if(alarm === true){\n        if(button === true){\n            let x = setTimeout(inching, timeout);\n            clearTimeout(x);\n            setTimeout(inching, timeout);\n            return [msg, null];\n        }\n        \n        if(button === false){\n            let x = setTimeout(inching, timeout);\n            clearTimeout(x);\n            return[msg, null];\n        }\n    }\n}\n\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":440,"y":340,"wires":[["beafdcd4.204e2"],["57ba979b.b50f18"]]},{"id":"57ba979b.b50f18","type":"ui_switch","z":"769faa02.df8de4","name":"","label":"10 sec inching","tooltip":"","group":"5b72dc71.346384","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":400,"y":520,"wires":[["81e9734d.cdef2"]]},{"id":"beafdcd4.204e2","type":"debug","z":"769faa02.df8de4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":280,"wires":[]},{"id":"f471301a.78d09","type":"comment","z":"769faa02.df8de4","name":"Set inching timout in seconds","info":"","x":260,"y":100,"wires":[]},{"id":"e9f0a16e.3d98c","type":"comment","z":"769faa02.df8de4","name":"Input","info":"","x":190,"y":240,"wires":[]},{"id":"61ae18ae.24db58","type":"inject","z":"769faa02.df8de4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":210,"y":280,"wires":[["81e9734d.cdef2"]]},{"id":"8296a7fb.4bf228","type":"inject","z":"769faa02.df8de4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":210,"y":320,"wires":[["81e9734d.cdef2"]]},{"id":"5d419be0.e6a9a4","type":"comment","z":"769faa02.df8de4","name":"Input (switch)","info":"","x":370,"y":480,"wires":[]},{"id":"9bb3ad95.68cff","type":"comment","z":"769faa02.df8de4","name":"output (branch1)","info":"","x":460,"y":300,"wires":[]},{"id":"a9d949e4.cab178","type":"trigger","z":"769faa02.df8de4","name":"","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"10","extend":false,"units":"s","reset":"false","bytopic":"all","outputs":1,"x":830,"y":520,"wires":[["95f4f2d9.b00d5"]]},{"id":"770d2a66.b8ff54","type":"comment","z":"769faa02.df8de4","name":"Input","info":"","x":610,"y":460,"wires":[]},{"id":"6a6ee941.7b64a8","type":"inject","z":"769faa02.df8de4","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":630,"y":500,"wires":[["a9d949e4.cab178"]]},{"id":"3d409c41.0962f4","type":"inject","z":"769faa02.df8de4","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":630,"y":540,"wires":[["a9d949e4.cab178"]]},{"id":"95f4f2d9.b00d5","type":"debug","z":"769faa02.df8de4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":520,"wires":[]},{"id":"5b72dc71.346384","type":"ui_group","z":"","name":"Inching in NodeRED","tab":"1d956ad4.4f89d5","order":1,"disp":true,"width":"6","collapse":false},{"id":"1d956ad4.4f89d5","type":"ui_tab","z":"","name":"Inching Switch","icon":"dashboard","disabled":false,"hidden":false}]

Flow Info

Created 4 years, 4 months ago
Updated 4 years, 1 month ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • comment (x5)
  • debug (x2)
  • function (x2)
  • inject (x5)
  • trigger (x1)
Other
  • tab (x1)
  • ui_group (x1)
  • ui_switch (x1)
  • ui_tab (x1)

Tags

  • switch
  • inching
  • timer
  • toggle
  • schedule
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option