Countdown Timer on HAI

JBTech

New Member
I have an electric water shutoff valve and would like to program it to close 1 hr after armed to away (in case the dishwasher or washer is on). Not real sure how to program.  Hoping somebody can save me some trial and error.  Would appreciate any suggestions for how to program.
Thanks
 
Use a flag as a countdown timer.
 
Define a Flag and give it a name, something like "Water Shutoff Timer"
In the code below I am using "Water Valve" for the output or unit that controls your water valve.
 
Then the program is easy.
 
 
WHEN AWAY
THEN Water Shutoff Timer ON FOR 1 HOUR
 
WHEN Water Shutoff Timer OFF
AND IF AWAY
THEN Water Valve OFF
 
WHEN OFF
THEN Water Valve ON
 
 
I added the AND IF AWAY conditional so that if you were only away for a short time *not a full hour) and came back before the timer ran out the valve would not shut off after you returned.
I added the third block to automatically turn the water back on when you return.
 
Instead of the AND IF AWAY conditional, you could add a set command to the OFF sequence of events, like this:
 
WHEN AWAY
THEN Water Shutoff Timer ON FOR 1 HOUR
 
WHEN Water Shutoff Timer OFF
THEN Water Valve OFF
 
WHEN OFF
THEN Water Valve ON
THEN Water Shutoff Timer SET TO 0
 
 
The "Set to 0" turns the flag state to off without generating an "OFF" trigger event.
However, the second way without the conditional can be a bit tricky.
You have to ensure you get the flag to an off state or it will keep counting down.
Once it counts down to 0, the second block of code will execute (regardless of the arming condition) and turn the water off.
So if any other block of code turns that timer on, you have to remember to set it to 0 if the timer has not yet reached 0.
 
Either way will work, the first method is more sure you don't have an inadvertent turning off of the water.
It really depends on other programming blocks as to which method ends up being more efficient.
 
Thanks for your help.  The first program looks pretty straight forward.  Doesn't matter but I am curious, If I Arm Away then realize I forgot something, Arm Off then Arm Away again 10 minutes later does the Countdown Timer restart the 1hr clock or is it still continuing to run from the first time I Armed Away? Can you please tell me where I might need to use the second program?
 
It should reset to an hour.

Timer rules.
If a timer is running and a rule that sets it to a longer duration than its current value the rule will reset it that duration, a rule that sets it to a shorter duration than its current value will be ignored.

So if you start running it at an hour and come back 5 min later the timer will be at about 55 minutes.
When you rearm it will be set back to 60 minutes.

You can add the set to 0 line in the WHEN OFF block to be absolutely sure it gets set to 0 but it shold not be necessary.
 
Back
Top