[RELEASE] Switch Timer with Reset


#1

Switch Timer with Reset
Modified version of @Cobra Switch Timer driver, with a reset if switch is triggered again before delay expires. It is 99% @Cobra code, I just added the reset for an application I needed.

Features:

  • Switch driver that has automatically switches OFF/ON after configurable delay
  • Configurable delay reset option - if switch is triggered again before delay expires, reset the delay timer
  • Unschedules any scheduled delay OFF/ON events if switch manually turned OFF/ON before delay expires

Installation:

  1. Install Driver code in Hubitat
  2. Create new virtual device, and define type as Switch Timer with Reset
  3. Open virtual device and configure preferences

Driver can be found on my GitHub

V1.0.0 - 1/5/19 - Initial Version


Stateless Virtual Switch
Rule became true but action did not run
Rule became true but action did not run
#2

Can I ask a question....if a switch is on, how do you "trigger it again"? Do you mean toggle it twice (off and back on)?


#3

A few ways, actually. Click the ON button from device details, write ON to it from app/code, etc.

Every time the ON event is triggered, regardless what the current state of the switch is, the ON event code runs.

Another example:
An RM sets a switch on when a door contact opens. Every time the contact opens, it triggers the switch ON event - RM does not look at the state of the activity device. Whether the switch is ON or OFF, it just sends the ON command when told to.

So every time the door opens, the switch timer resets. I use this for a few things I don't want repeated in a high frequency if people are coming in/out of the door. I find this more straight forward than using the RM private boolean/off delays to prevent quickly repeated executions.

But there are many ways to do the same thing.

Could also use it for a watchdog or dead man timer, too. And with a small code changer could use it as a '# of times something happened within a time period' counter.


#4

Okay...so this is more of a "variable storage device" than a device you would actually interact with then? That makes sense to me. I was sitting over here going, "If you trigger an on switch, it turns off". I was not going that route. I was like, "Is this guy losing it or is it just me?" :stuck_out_tongue:

I do the same thing but with PB. Like you said, many ways to do the same thing. Thanks for explaining though.


#5

Well, I use one RM to mirror a door contact to the virtual switch.

Then I use that virtual switch for all of the logic/RM/apps I want to use that contact for,