Since Defer applies to the whole program, you need to create a separate virtual output to monitor the momentary switch and apply the Defer there. However, another issue is that a momentary button must remain pressed the whole time for the Defer to take effect, so a 2nd virtual output should be used to detect the initial press and release, while the other virtual output acts as the Defer timer. Then use the status of the Defer virtual output to control the powerhead
The example below would result in the powerhead turning off 5 minutes after pressing the button, then turning back on 1 minute later. (6 minute Min Time minus 5 minute Defer). Just adjust the times to your preference.
[vButton_Press] — virtual output 1 to detect the button press & release, but remain on for 6 minutes:
Set OFF
If but1 CLOSED Then ON
Min Time 006:00 Then ON
[vButton_Delay] — virtual output 2 to start the Defer timer for 5 minutes when the above output is on:
Set OFF
If Output vButton_Press ON Then ON
Defer 005:00 Then ON
[Powerhead]
Set ON
If sw1 CLOSED Then OFF
If Output vButton_Delay = ON Then OFF
If you’re not familiar with virtual outputs, see my tutorial here:
Part 5 of our Apex Programming Tutorials. This one is on Virtual Outputs.
www.reef2reef.com