Switch Rollback

I created a Virtual Switch but don't see a 'rollback' property that I can configure. e.g. when the switch is turned on, turn it off after X seconds.

Can this be done with Rule Machine or an alternative method?

[Edit] Yes, use 'Set Mode, Variables or File, Run Custom Action' and then configure Delay[/Edit]

Screen Shot 2020-08-22 at 3.08.56 PM Screen Shot 2020-08-22 at 3.09.11 PM

Not sure I understand your question, since Virtual Switch driver has an Enable Auto Off option.

1 Like

:+1:

@Busthead I always start by asking what you are trying to do? If you describe why you need this, it might make a difference what we recommend. For example you might be able to use Simple Automation or be required to use Rule Machine depending upon what the end goal is. Maybe a community app would be better for your end goal?

But yea, virtual switches can turn off after X seconds by going to the device tab, and going to this specific device.

1 Like

I saw the 'Enable auto off' but that doesn't appear to be a property I can configure to any value. i.e. I have to choose from the pre-populated list and cannot set, for example, five minutes.

Yes, the driver exposes a few specific values. If you want something different, you can either write/use your own virtual switch driver (with whatever options you want) or use an app to handle the automatic "off" instead of the driver. For the latter, Rule Machine or any of the "switch timer"-type community apps would work. Either option here would probably work just as well. But again, if you explain what your ultimate goal is, someone might have an idea that would work even better to get there instead.

1 Like

My ultimate goal is to turn a switch off five minutes after it is turned on.

Is the code for the build-in Virtual Switch published somewhere so I can copy and modify?

Thx

A real switch or a virtual switch? If it's a virtual switch, surely you have some goal besides just turning the switch off. If it's a real switch, we're talking about virtual switches (and drivers) here, so this is unlikely to help.

No, Hubitat's apps and drivers are closed-source, though they have published a few examples. That being said, virtual drivers for one-trick devices like these are pretty easy to write for someone who knows what they're doing. My guess is there's probably something out there that's close, otherwise I could probably create something later if someone doesn't get there first. But aside from needing one less app, I don't see a reason that you'd need to do this in the driver; a simple Rule like the following would do just as well:

Trigger: Switch on

Actions:

Cancel Delayed Actions
Delay 0:05:00 (cancelable)
Off: Switch

But again, whether this is really a good route to go probably depends on what you're actually doing.

1 Like

Just found the 'Set Mode, Variables or File, Run Custom Action' option Rule Machine that has a Delay configuration.

Not sure if you edited your post or if I'm missing something, but the "Delay" action is found under the "Delay or Repeat Actions, Wait" category. You could also just check the "Delay" action you'll see when creating the "Off" (or any) action, though I personally prefer separate actions and there are differences if you have more actions (which you don't in this rule). In either case, checking the "Cancel?" option is key to resetting this timer if the switch is turned off and back on again within the countdown.

1 Like

Actually, you can do this. Open the enumerated list in a web inspector and add a custom value for 300 seconds. I’ve done it with a few of my switches.

2 Likes