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","topic":"","payload":"10","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"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,"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    if(alarm === 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,"x":440,"y":300,"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":280,"y":440,"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":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":280,"wires":[["81e9734d.cdef2"]]},{"id":"8296a7fb.4bf228","type":"inject","z":"769faa02.df8de4","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":320,"wires":[["81e9734d.cdef2"]]},{"id":"5d419be0.e6a9a4","type":"comment","z":"769faa02.df8de4","name":"Input (switch)","info":"","x":190,"y":400,"wires":[]},{"id":"9bb3ad95.68cff","type":"comment","z":"769faa02.df8de4","name":"output (banch1)","info":"","x":580,"y":260,"wires":[]},{"id":"5b72dc71.346384","type":"ui_group","z":"","name":"Inching in NodeRED","tab":"1d956ad4.4f89d5","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 1 month, 1 week ago
Rating: not yet rated

Node Types

Core
  • comment (x4)
  • debug (x1)
  • function (x2)
  • inject (x3)
  • tab (x1)
Other
  • 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