Switch Node with Limited 'on' time

Hi,
Does anyone know of a ui-node like the switch node, where there is a time limit for the 'on' time.

For example I wish to switch on an irrigation system for a maximum of 5 minutes. This is easy enough to schedule using a timer and use trigger node to time it.
However in order to maintain 'manual' control I have to jump through hoops to be able to turn 'off' a device using the UI Switch before the timer runs-out, AND have the actual status reflected in UI Switch.

I emphasise I have a solution, but it's pretty 'messy'.

Sorry meant to add that if the UI Switch is used, the maximum time 'on' should be maintained in case I forget to switch it 'off'.

so if you flip the switch on, you want it to be shut off 5 minutes later correct?

If so, feed the output of the ui_switch to a switch node and test for boolean true and false. Wire the true output to a delay node (set it to the delay you want -5 minutes) and to the nodes that turns on the water. Connect the delay node to a change node which sets msg.payload to boolean false and the oputut of this is tied back to the ui_switch's input.

The false side of the switch node would be tied to nodes to shut off the water

Why not use the MyTimeout node from Neil Cherry ? It accepts input for various actions/states and seems to do what you want.

Your UI switch would read something like Manual Turn on for 5 minutes - it would then push input to the MyTimeout Node

Craig

Thanks both - I will try out these ides and the MyTimeout node.

Appreciate your responses.

Here is an example of how i am using the MyTImeout node in one of my flows

[{"id":"be23d858.f070d8","type":"debug","z":"a78930fe.ed232","name":"Boiler Fire up - Node 1","active":false,"tosidebar":true,"console":true,"tostatus":false,"complete":"payload","x":930,"y":1180,"wires":[]},{"id":"5bab8b3b.564f94","type":"mqtt out","z":"a78930fe.ed232","name":"","topic":"cmnd/ArduinoLive/BoilerControl","qos":"","retain":"","broker":"389dd264.7716de","x":950,"y":1220,"wires":[]},{"id":"e1483885.249c28","type":"inject","z":"a78930fe.ed232","name":"Turn off Boiler - Manual","topic":"cmnd/ArduinoLive/BoilerControl","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":180,"y":1260,"wires":[["5f3a7a46.e835c4"]]},{"id":"15a8756f.b0232b","type":"ui_button","z":"a78930fe.ed232","name":"Manual Turn on of Boiler 1hr","group":"4da5d3cb.b9673c","order":1,"width":0,"height":0,"passthru":false,"label":"Manual Boiler 1 Hr Turn on","color":"","bgcolor":"","icon":"","payload":"{     \"payload\": \"on\",     \"timeout\": 3600,     \"warning\": 5 }","payloadType":"json","topic":"cmnd/ArduinoLive/BoilerControl","x":180,"y":1180,"wires":[["5f3a7a46.e835c4"]]},{"id":"d5c02b4c.5620c8","type":"ui_button","z":"a78930fe.ed232","name":"Turn off Manual Boiler Override","group":"4da5d3cb.b9673c","order":4,"width":0,"height":0,"passthru":false,"label":"Turn off Manual Boiler Override","color":"","bgcolor":"","icon":"","payload":"0","payloadType":"str","topic":"cmnd/ArduinoLive/BoilerControl","x":190,"y":1220,"wires":[["5f3a7a46.e835c4"]]},{"id":"23210b71.6a2104","type":"debug","z":"a78930fe.ed232","name":"Boiler Fire up - Node 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":920,"y":1280,"wires":[]},{"id":"e56bee14.2f24b","type":"ui_button","z":"a78930fe.ed232","name":"Manual Turn on of Boiler 2hr","group":"4da5d3cb.b9673c","order":2,"width":0,"height":0,"passthru":false,"label":"Manual Boiler 2 Hr Turn on","color":"","bgcolor":"","icon":"","payload":"{     \"payload\": \"on\",     \"timeout\": 7200,     \"warning\": 5 }","payloadType":"json","topic":"cmnd/ArduinoLive/BoilerControl","x":180,"y":1140,"wires":[["5f3a7a46.e835c4"]]},{"id":"5f3a7a46.e835c4","type":"mytimeout","z":"a78930fe.ed232","name":"Boiler Manual Turn on - New Node","outtopic":"cmnd/ArduinoLive/BoilerControl","outsafe":"1","outwarning":"","outunsafe":"0","warning":"2","timer":"10","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":600,"y":1180,"wires":[["5bab8b3b.564f94","be23d858.f070d8"],["23210b71.6a2104","34467ea3.dbffa2"]]},{"id":"caf1a13f.d8d6","type":"change","z":"a78930fe.ed232","name":"Take Variable and Put into Payload","rules":[{"t":"move","p":"CIrculatingPumpTimeToRun","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":1080,"wires":[["d5602c1e.081f4"]]},{"id":"d5602c1e.081f4","type":"ui_text_input","z":"a78930fe.ed232","name":"","label":"Manual Pump - Time to run (Sec)","group":"2b345d73.f4d042","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":960,"y":1080,"wires":[[]]},{"id":"34467ea3.dbffa2","type":"change","z":"a78930fe.ed232","name":"Set Flow Variable - BoilerTimeToRun","rules":[{"t":"set","p":"BoilerTimeToRun","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1280,"wires":[["9cd8ac49.7c2aa"]]},{"id":"9cd8ac49.7c2aa","type":"change","z":"a78930fe.ed232","name":"Take Variable and Put it into Payload","rules":[{"t":"move","p":"BoilerTimeToRun","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":1340,"wires":[["fc794523.ba6918"]]},{"id":"fc794523.ba6918","type":"ui_text_input","z":"a78930fe.ed232","name":"","label":"Manual Boiler  - Time to run (Sec)","group":"4da5d3cb.b9673c","order":5,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":960,"y":1340,"wires":[[]]},{"id":"8d1a36bc.c9e098","type":"ui_button","z":"a78930fe.ed232","name":"Manual Turn on of Boiler 4hr","group":"4da5d3cb.b9673c","order":3,"width":0,"height":0,"passthru":false,"label":"Manual Boiler 4 Hr Turn on","color":"","bgcolor":"","icon":"","payload":"{     \"payload\": \"on\",     \"timeout\": 14400,     \"warning\": 5 }","payloadType":"json","topic":"cmnd/ArduinoLive/BoilerControl","x":180,"y":1100,"wires":[["5f3a7a46.e835c4"]]},{"id":"389dd264.7716de","type":"mqtt-broker","z":"a78930fe.ed232","broker":"localhost","port":"1883","clientid":"Node-Red","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"4da5d3cb.b9673c","type":"ui_group","z":"","name":"Boiler Control","tab":"c9d53e06.a95c8","order":7,"disp":true,"width":"6","collapse":false},{"id":"2b345d73.f4d042","type":"ui_group","z":"","name":"Circulating Pump Control","tab":"c9d53e06.a95c8","order":6,"disp":true,"width":"6","collapse":false},{"id":"c9d53e06.a95c8","type":"ui_tab","z":"","name":"CURTIN house main page","icon":"dashboard","order":1}]

Craig

Sorry All - I have been away.

I have looked at the solutions and appreciate all your contributions.
They don't quite fit the bill due to my use of the UI Switch interface. I have used it a lot in my design due to it's appealing visual feedback (well to SWMBO which is most important!!).

Below are my test set-ups outputting only to debug, but it gives the idea of what I am trying to achieve. As I have said I have a solution - it just seems messy trying to cope with the UI.

Thanks again to everybody - I hope this generates interest for other ideas also.

Regards
SWMBO = "She Who Must Be Obeyed".

(Also as I wrote this I realised I do not know how to include a flow properly - could someone advise plse)

[{"id":"65383bb5.fb8884","type":"inject","z":"89f9bcc1.fe854","name":"Send 1","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":216.5,"y":149,"wires":[["40e3451c.113f7c","7529ffde.844f1","b5907ab6.2c2838"]]},{"id":"b5907ab6.2c2838","type":"debug","z":"89f9bcc1.fe854","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":782.5,"y":146,"wires":[]},{"id":"40e3451c.113f7c","type":"trigger","z":"89f9bcc1.fe854","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"15","extend":false,"units":"s","reset":"","bytopic":"all","name":"Pulse for 15 secs","x":525.5,"y":116,"wires":[["b5907ab6.2c2838","7529ffde.844f1"]]},{"id":"7529ffde.844f1","type":"ui_switch","z":"89f9bcc1.fe854","name":"Fountain on for 15 Secs","label":"Fountain Test","tooltip":"","group":"7233fc05.44414c","order":1,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"X10/N/1","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":536.5,"y":180,"wires":[["b5907ab6.2c2838","40e3451c.113f7c"]]},{"id":"a663a6ba.487188","type":"debug","z":"89f9bcc1.fe854","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":641,"y":266,"wires":[]},{"id":"72b0e3a0.ac1e6c","type":"inject","z":"89f9bcc1.fe854","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":291,"y":266,"wires":[["5ab6e51d.70ddfc","a663a6ba.487188"]]},{"id":"5ab6e51d.70ddfc","type":"trigger","z":"89f9bcc1.fe854","op1":"","op2":"timeout","op1type":"nul","op2type":"str","duration":"5","extend":true,"units":"s","reset":"","bytopic":"all","name":"Watchdog","x":461,"y":306,"wires":[["ec1e4988.4497f8"]]},{"id":"ec1e4988.4497f8","type":"debug","z":"89f9bcc1.fe854","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":641,"y":306,"wires":[]},{"id":"ffcc7771.debd58","type":"mytimeout","z":"89f9bcc1.fe854","name":"10 second timeout","outtopic":"","outsafe":"1","outwarning":"","outunsafe":"0","warning":"","timer":"10","debug":false,"ndebug":false,"ignoreCase":true,"repeat":false,"again":false,"x":552,"y":502,"wires":[["36596a5f.799616","d717ca5a.527b58"],[]]},{"id":"e6c2e651.1ecde8","type":"inject","z":"89f9bcc1.fe854","name":"Send 1","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":205,"y":401.5000066757202,"wires":[["d717ca5a.527b58"]]},{"id":"36596a5f.799616","type":"debug","z":"89f9bcc1.fe854","name":"Output 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":780,"y":468,"wires":[]},{"id":"7c956558.a06cbc","type":"debug","z":"89f9bcc1.fe854","name":"Output 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":782.2500114440918,"y":401.0000057220459,"wires":[]},{"id":"99b2b381.be7fa","type":"inject","z":"89f9bcc1.fe854","name":"Send 0","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":209,"y":460.25000762939453,"wires":[["d717ca5a.527b58"]]},{"id":"d717ca5a.527b58","type":"ui_switch","z":"89f9bcc1.fe854","name":"Fountain on for 15 Seconds","label":"Fountain Test","tooltip":"","group":"7233fc05.44414c","order":1,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"X10/N/1","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":567,"y":402,"wires":[["ffcc7771.debd58","7c956558.a06cbc"]]},{"id":"7233fc05.44414c","type":"ui_group","z":"","name":"Test","tab":"1445f2eb.b6dfed","disp":true,"width":"16","collapse":false},{"id":"1445f2eb.b6dfed","type":"ui_tab","z":"","name":"Test Area","icon":"wi-wu-sunny","disabled":false,"hidden":false}]

Wrap the flow in back-ticks - or use the image icon in the editor.

Surely if you are using Dashboard to provide a friendly interface, all you need is to send the switch output to a flow that sends an on value direct AND sends a matching off command via a delay node at the same time?

See the flow I've just posted regarding a simple button to turn off a light after a 5 minute delay for how to do the delay flow.

Thanks. Thought I had tried that so must be finger trouble.

I will try your suggestion. I couldn't help feeling that I was just overcomplicating everything. I couldn't find your flow though ...

Once I set out to try it I realised that is what I had come up with anyway.
I might try my hand at writing a node.