Need help setting up Switch Timer with resetting time when switch is repressed

Hey guys I have read and read and came across a bunch of informative articles. Unfortunately none that do what I am trying to do. It is something maybe very very specific.

So I just purchased a new home and decided to go with Hubitat VS ST. I had ST on my previous home, but love how unique and customizable Hubitat is!

Long story short I have everything working properly, but I am trying to set a switch to automatically turn off after 30 mins. Sounds easy enough, the kicker however is that I want to be able to reset that 30 min timer when the switch is turned on again even if it's already on.

Let me give you more info... It is for my water heater switch (My house has propane so it is very expensive to have water recirculating 24/7, with switch off hot water never comes out) . I must turn on this current switch that has a 10, 30 and 60 min timer built in anytime I want to shower, or use hot water period. Part of getting home automation for me is to be even lazier and not have to walk all the way to garage to turn on hot water, so I want to put a switch to automatically turn on the hot water. I also want to have a timer set so hot water automatically turns off after 30 mins which is very easy to do. HOWEVER having kids I want to be able to reset timer anytime my son says ALEXA turn on hot water.

In short if I say Alexa turn on hot water (name for switch) and my hot water turns on 30 min timer starts. Now lets say my son 27 minutes later wants to shower, and says Alexa turn on hot water I would want the 30 mins to be reset so he doesn't get ice cold water 3 mins later. Rather than saying Alexa turn off hot water, then Alexa turn on hot water.

I know it may sound overkill, but as soon as I turn off switch cold water starts coming out, so if someone is showering when they say Alexa turn off hot water to reset it the person showering will unpleasantly surprised with cold water!

I hope this isn't too crazy and thanks in advance


If I understand what you want it should be fairly easy. I would create a Virtual switch called StartTimer for example.

Then whenever you say Alexa, turn on Hot water, I would create an Alexa Routine for this, it would turn on this virtual switch. You can set the virtual switch to auto turn off in 5 seconds. You do that on the devices config page. Below would be the RM script


StartTimer, virtual switch, turning on.


cancel delayed actions
turn on the Hot water heater switch.
Turn off the Hot water heater switch with a delay of 30 minutes and make it cancelable.

With this every time the StartTimer switch is turned on it will cancel the delay that turns off the switch and start it again.

Other ways to do this as well, but this would be my approach.

1 Like

Wow thanks a ton!! that was amazing! Just tested it and works great! Now my other question...

how can I make switch turns off automatically when someone turns it manually?

I got it working with switch also! So now I can turn on with alexa and anytime i say turn on hot water it resets timer!

also if i manually turn on switch its set to turn off automatically in 30 mins, and it's cancealable by virtual switch in case i tell alexa it resets it!

Thanks a ton!

here is how i set up virtual switch rule

and here is how I set up physical switch

1 Like

Yeah that should work. You have the Virtual switch set to auto turn off in 5 Sec, correct? If so that should be enough time for the manual switch switch delay to be canceled.

I think I would do the following, however. I would want to have the second rule trigger on Start Timer turning on as well. If someone uses Alexa after a manual turn on, the second rule delay will not get canceled and the hot water would turn off after the 25 minutes,

The second rule could be:

Hot water Heater on
Start Timer ON

IF Start Timer on then 
    Cancel delayed action 
    Turn off hot water with delay

With this second rule if your hot water is turned on manually the rule is triggered but since Start Timer is off a 25 minute delay to turn it off is initiated. If Start Timer is turned on some time later the rule is triggered again but since it is now on it will cancel this rule's timer, and this rule will not turn off the hot water heater. The other rule should handle that now.

You might could do this in one rule but two is probably better. I try to avoid doing something in a rule that would then re-trigger the rule. So having a rule that turns on the hot water and one of it's triggers is the hot water turning on can cause issues.

1 Like

sounds good, thanks again so much!

I am a bit confused yet again. It seems easy to do but I am having a heck of a time. I ended up deleting second rule. Trying to make a new one the way you suggested .

Go to RM

Create new Rule named it Hot Water Auto OFF

Select trigger events : switch - selected water heater (physical switch) then done then select start timer (virtual switch) then done

so it says trigger events water heater on or start timer on

Then I go to action and I select conditional actions? then if then? then select start timer on THEN

cancel delayed actions


Off:Water Heater *__> delayed: 0:25:00


alexa still works as it should resetting timer, but when i physically turn on switch it always turns off in specific amount of time even if i tell alexa to turn on water it does not reset physical switch timer

Here is the rule I use for Alexa that resets timer when I re run it

Here is the auto off for physical switch that turns off after 25 mins (30 secs to test) but when i rune alexa it does not reset timer

ork when i tell alexa

You need to make the delayed action in 2nd rule cancelable like you did in first.

1 Like

Awesome, again thanks so much! It's all working as it should!!

Download the Hubitat app