How to set Virtual Switch auto off to more than 5 seconds?

I have a Hubitat C8. This little box is amazingly powerful. I’m using this to replace my Raspberry Pi running HomeBridge. Only remaining item I need to move over is resetable virtual switches. What i need is a Virtual Switch that will turn off after pre-configurable minutes (like 3 or 10 minutes). And if the Virtual Switch is turned on again (by automation), the timer should reset and start counting down again. I must use Hubitat’s Virtual Switch (not by custom app/driver) since HomeKit Integration will only expose Hubitat’s offical devices.
I have multiple motion sensors in the kitchen on HomeKit system. When motion is detected by any of these motion sensor, i have an automation that would turn on the Virtual Switch. I also have a HomeKit automation rule if the Virtual Switch is turned off, then turn off all lights in the kitchen. So, i would need the Virtual Switch to reset the timer/delay. I hope this make sense. Thanks!

1 Like

You would need either a custom virtual switch driver (one probably exists somewhere, or would be easy enough to write) or use some other method to "auto turn off" the switch. That last thing is pretty easy and could be done with built-in tools, including something simple like Basic Rule:

Couple of options. One option would be to have the switch go to off after only the 5 seconds. For your rule to turn the lights off, have it as a "and stays" trigger, set it to stays for 5 minutes for example. You could even use Room Lighting for this I think, instead of a custom rule. It could handle the turn on and the turn off with the stays delay all in one app. I think it allows stays for switches anyway...

Other option @bertabcd1234 posted while I was typing this. Use a rule to turn it off instead of the setting on the switch.

The method I use is a user app called Auto Off. :slight_smile:

Available on Hubitat Package Manager.

1 Like

Here's another good one, also on HPM:

https://raw.githubusercontent.com/apwelsh/hubitat/master/devices/timer-device.groovy

I forgot that I also have such an app. :smiley: (It can do more, but it will fit this use case if you select the "same switch" option, as it also lets you create a separate "timed" switch if you want to use it separately from the actual switch.)

This driver has up to 60 minutes delay.

I too wrote a driver for auto-off virtual switch. I added 2 features I needed, besides giving a larger choice set on the timer setting. Auto-off, Toggle and Reversed. My need at that time was I want a switch to show ON when an trigger was off. Regardless, Maybe my driver might fit your needs?


It is found in Hubitat Package Manager with a search for 'Autooff'

1 Like

People need to read the first post a little better. He cannot use a custom driver due to Homekit restrictions.

3 Likes

Oops. Missed that.