[RELEASE] Timed Switch Helper

Link to code on GitHub: https://github.com/RMoRobert/Hubitat/tree/master/apps/TimedSwitchHelper

I thought I'd share a small app I threw together to handle a situation I use quite a bit, virtual "timed switches" that I want tied to "real" switches. For example, if I have a virtual switch called "Timed Kitchen Fan," I want it to turn on Kitchen Fan ("real" switch) for the specified period of time, then turn it off. If I manually turn off "Timed Kitchen Fan" before the timer is up, I'd also like "Kitchen Fan" to turn off (and delete/reset the timer so it will start a new countdown if I turn it on again).

This is actually pretty easy to handle in Rule Machine:

image

However, I got tired of creating the same rule again and again, and since there's no way to clone existing rules (EDIT: there is now, but I still find this easier than writing a rule; also, the screenshot above is from an older version of Rule Machine that most people will no longer have, though could do something equally easy in current versions), I thought I'd write an app to make it easier. Note that my app does exactly what this rule does--it effectively turns off the "real" switch when the timer is up, but it actually does this by way of turning off the "timed" switch; turning off the timed switch is technically what triggers handles turning off the real switch. That way, you can turn off the timed switch yourself before the timer is up if you so choose. Here's my app:

image

For the "timed" switch, you can use anything, but I'd recommend using a virtual switch you create just for this purpose. Do NOT set the virtual switch to automatically turn off after any amount of time in the driver (unless for some reason you really need that for something else and also want it here)--this app handles that on its own. As of version 2, you can also use this app to simply turn off any (real or virtual) switch after it turns on and/or stays on for a certain amount of time.

See the second post in this thread, below, for screenshots of the current version.

Hope someone finds this useful! I may expand it in the future to add additional features (I have a virtual "Overnight Window Fan" switch I want to turn off at a specific time, not in a specific amount of time, for example, but I'm currently handling that with RM). Again, it's not too hard to do in RM, but this is a bit less clicking if you do this a lot.

6 Likes

If anyone is using this, I just updated both parent and child apps to version 2 and revamped the UI a bit, adding more explicit options for things that were implicit before:

I also made it less awkward to automatically "time" a single (probably real, but virtual works too) switch, basically a time limit for how long it can be left on:

Nowadays, if that's all you want, Basic Rule can do it pretty easily (even simpler than RM, which would also work), but it's still a bit less clicking if you have a lot of these automations or want to keep both this and the "other" kind all under one roof (the parent app).

NOTE for those upgrading from 1.x: overwrite the existing parent and child app code (as you would normally do), then go into each installed (child) instance and hit "Done."

Also, I don't have this in HPM (any version) but can add it if there is any interest.

3 Likes

Now I may need this, let me explain my situation and hopefully you could help!

I have right now this switch pictured below that controls my water heater recirculation. I need to turn it on anytime I want a hot shower, or do the dishes w warm water etc. Basically anytime I want hot water.

One of my biggest point of automation is lazyness :sweat_smile:

I hate sometimes having to walk across my whole house to turn on hot water for a shower.

Can I add a normal zwave switch and have it turn off automatically after 30 mins of it being on with this?

What about if theres 10 minutes left in the timer and my son says Alexa turn on water heater will it reset to 30 mins?

I tried auto off and had issues. Problem is my house runs off propane so having this on all the time is very very expensive.

I hope I kind of explained what I need.. In short a switch that turns off automatically always after 30 mins, and timer resets when it is "turned on" even though it's already on??

Thanks!

Hector

( it did not let me add pic here)

Yes, but if you're using recent hub firmware, you can also do this with the new built-in Basic Rules app, so you may want to check that out first.

Is "water heater" the name of the actual switch (for example, the same as the one above?). If, so no, or at least usually not--turning "on" a switch that is already on is unlikely to generate an event on Hubitat, and without an event, the app will not "see" anything or be able to start/restart a timer. Turning it off and back on would work, but if this immediately controls your water heater, you may not want that; maybe using a virtual switch as a "proxy" between voice commands/timers and the real switch would help--just one idea. (Or maybe this isn't really a problem for you, then the real switch will still work as long as you can get some event.)

Well I have yet to install the switch because I am worried it won't work perfectly. I was testing with AUTO OFF on a regular zwave switch and ran into many issues doing what I am trying to do. My concern mainly is that my kids will just say Alexa turn on hot water or whatever I name switch but switch is already on and there's 3 mins left because maybe I had already turned to on 27 mins before and cold water starts coming out lol.

So that's what I am trying to figure out before I install the actual switch.

So

Can I not edit posts? I needed to add info... I was going to say maybe there's a way to run a rule or scene to turn off the hot water switch for 30 seconds then on anytime we run that scene or rule? Sorry for hijacking it seems now! Anyhow your app looks great and I will use it for other things such as my restrooms fan!

You will get this permission soon. You have to post a certain number of times, read posts, and a couple other things.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.