Hi, I have a simple flow which turns on and off a light.(I have also integrated it with alexa so i can ask alexa to turn the light on and off). I'm trying to find a way that i can have a range of 4 switches that can turn the light on for preset amount of time. Each switch can be set to 30 minute intervals so the first switch will turn the light on for 30mins and the last switch will turn the light on for 240mins. Im quite new to node-red and still trying to get my head around the workings of node-red. Cheers....
sw1 = turn on light = delay(30 minutes) => turn light off
sw2 = turn on light = delay(60 minutes) => turn light off
sw3 = turn on light = delay(90 minutes) => turn light off
Or possibly simpler use the Trigger node to send the On message then later the off.
One issue to watch out for though in both the above solutions is what happens if you you press another button before the first on/off action has completed. With the Trigger node you can arrange for each button to also send reset messages to the other trigger nodes.
Hi guys, thanks for your excellent replies. Got it working using the trigger node. 4 toggles with 30 minute intervals. Is there a way that the toggle switch reverts back to off after the period has timed out. Although the light will go out, the toggle switch in the UI still shows it as being on. Also, would be nice if there was a countdown timer visible in the UI with time remaining until the light goes off. Many thanks for your help, very much appreciated....
You can feed the Trigger output back to the switch, with a change node if necessary, to set the switch to the appropriate state. Might also need a (non dashboard) Switch node to only feed the Off state back.
take a look at node-red-contrib-mytimeout that you could feed to a change node to change the time to hh:mm format then to a ui_text node. You could also send it to a ui_guage in donut mode to have a visual countdown. That is what I juse in my Coffee Pot Timer project