Installing a timer for a switch

Hi all,

I'm creating this topic in good faith that someone on this forum can be able to help a new Node-RED'er.
I have made a basic flow which activates a function with a ON / OFF switch, connected to a LED light to display if the switch is on or off.

What I want to have integrated in the flow is a timer (not a scheduler) which cuts off the activated signal after X-seconds. Say I turn the switch ON, then the switch should go back to OFF after x-seconds of being active.

Have any of you got tips / tricks on what I could use to make this achievable?
Is it possible to use Big Timer or Timerswitch for this purpose?

Best regards
Alex

Yes Pete Scargills big timer can do this, there's a recent youtube video where he inject 5 seconds.

You can do that with a Trigger node, set it to send the On message then X secs later send the Off.

1 Like

Watched the video, but this is a different approach than what I am searching for.
What I am searching for is something like this:

My UI is as of now very simple:
image

I want to be able to use the interface in such a way that when I'm turning the switch on, it will stay active for 5 seconds then it will deactivate itself.

Is there a easy way to do this?

How is the trigger going to do anything like this ?

Try: switch -> trigger -> output.

To be honest I'm not completely sure how to set this up. My first thought was that the Trigger would activate the switch and keep it on for a certain amount of time, but this didn't work.
I have now also tried with placing the trigger after the switch and it still doesn't work, this might be because I have the wrong inputs. Any idea on what I can set the input to be in order to make this work?

Try this:

[{"id":"ecee5ec1.2c4bd","type":"ui_switch","z":"ed398e74.b27cc8","name":"","label":"switch","tooltip":"","group":"16261705.69f239","order":3,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":358,"y":352,"wires":[["5214e0c2.3184c"]]},{"id":"5214e0c2.3184c","type":"trigger","z":"ed398e74.b27cc8","op1":"","op2":"false","op1type":"pay","op2type":"bool","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":368,"y":264,"wires":[["3a57a21b.ec1a96","ecee5ec1.2c4bd"]]},{"id":"3a57a21b.ec1a96","type":"debug","z":"ed398e74.b27cc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":554,"y":264,"wires":[]},{"id":"16261705.69f239","type":"ui_group","z":"","name":"switch","tab":"e30dbcbc.9fce1","order":1,"disp":false,"width":"6","collapse":false},{"id":"e30dbcbc.9fce1","type":"ui_tab","z":"","name":"New","icon":"fa-th","order":1,"disabled":false,"hidden":false}]```
1 Like

Thanks alot! This worked out perfectly.

1 Like