Author Topic: Countdown timer plugin (UI5)  (Read 60208 times)

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Countdown timer plugin (UI5)
« on: February 09, 2012, 06:38:19 am »
I've just put a plugin onto apps.mios.com that makes scriptable countdown timer devices.  Combined with scenes, this plugin can eliminate the need to use Luup in several real-world scenarios.

Fetch the plugin here: Countdown timer. This plugin is UI5/6 only.

By itself, a countdown timer doesn't do much. When the Start button is pressed, a timer counts down seconds from a (configurable) start value.  Left to its own devices, when the timer hits zero, it stops.

What makes the plugin useful is that the Start button is scriptable: like a virtual switch it can be run as a target action for any scene. Any Vera event can start a timer.

There is also a Cancel button to abort a timer.  That, too, can be triggered by a scene.

For more complicated scening, there is a Restart button that does exactly the same as Start, except that it resets the timer back to its start duration even if it's currently counting down.  Finally, there's a Force button, equivalent to grabbing the kitchen timer and wrenching it down to zero (ding!).

When a timer completes, or if it's cancelled, the timer device triggers an event.  You can use this event to start a scene that can make your Vera do anything that is scenable.

Timers can be Muted, which just prevents them from generating an event.  This might be useful if you want to disable a timer during a certain time of the day: it still counts down but doesn't go Ding.

Tip for creating multiple timers: Apps > Countdown Timer > Create Another.

Some scenarios in the next post.
« Last Edit: June 12, 2014, 05:47:32 pm by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Re: Countdown timer plugin (UI5)
« Reply #1 on: February 09, 2012, 06:39:30 am »
« Last Edit: May 28, 2012, 06:26:27 pm by futzle »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Countdown timer example: turn off a light after 5 minutes
« Reply #2 on: February 09, 2012, 03:49:42 pm »
In this example, imagine that you have a light that you want to turn off five minutes after it is turned on.  If the light is turned off manually before 5 minutes, do nothing.

1. Create a Countdown Timer. Rename it Five minute timer. Go to the configuration tab and change the Duration to 300 seconds.
2. Create a scene. Rename it Light goes on. Edit the scene, setting a trigger for the light device: A device is turned on or off > Device is turned on. Make the scene activate the Start button on the Five Minute Timer.
3. Create a second scene. Rename it Light goes off. Edit the scene, setting a trigger for the light device: A device is turned on or off > Device is turned off. Make the scene activate the Cancel button on the Five Minute Timer.
4. Create a third scene. Rename it Turn light off. Edit the scene, setting a trigger for the Five Minute Timer: Timer completes while not muted. Make the scene activate the Off button on the light device.

Mute the timer to temporarily override the automatic turning off of the light.
« Last Edit: February 09, 2012, 03:53:11 pm by futzle »

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1037
  • Karma: +37/-14
Re: Countdown timer plugin (UI5)
« Reply #3 on: February 10, 2012, 04:41:54 am »
Nice, that's a very pretty solution for this kind of problem (disarming alarm systems):
http://forum.micasaverde.com/index.php/topic,8996.0.html
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Countdown timer example: DIY alarm entry delay
« Reply #4 on: February 10, 2012, 04:43:03 am »
Though I wouldn't recommend it from a security perspective, you can roll your own alarm system from components. In this example, assume you have a Z-Wave motion sensor, a Z-Wave scene controller like a Minimote and a siren connected to a Z-Wave appliance module.

When you come home and trip the motion sensor, you want thirty seconds' grace to find the Minimote and press a button on it to prevent the siren from going off.

1. Create a Countdown timer device. Rename it to Entry delay and edit the device and set its duration to 30 seconds.
2. Create a scene. Rename it to Sensor tripped. Set a trigger for the motion sensor An armed sensor is tripped. Add an action to Start the Entry delay timer.
3. Create a second scene. Rename it to Minimote pressed. Add an action to Cancel the Entry delay timer. Add an action to Bypass the motion sensor. Configure the Minimote to call this scene when a button its pressed.
4. Create a third scene. Rename it to Sound siren. Set a trigger for the Entry delay Timer completes while not muted. Add an action to Turn on the appliance module that is connected to the siren.

Dedicated security systems also have an exit delay for when you leave the house. This can be achieved with another countdown timer and two more scenes (and one more button on your Minimote). Dedicated security systems also will sound the siren for only a set time (a few minutes) to avoid Disturbing the Peace. This can also be achieved with a countdown timer and two more scenes.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Countdown timer example: automatic security light
« Reply #5 on: February 11, 2012, 02:16:31 am »
If you have motion sensors in the same room as Z-wave lights then you might want to have detected motion turn on the light.  This may be for security, safety or convenience.  Naturally, when the motion stops you will want the light to turn back off.

MiOS has this functionality built in for security sensors but if you want additional control or want to trigger the light with other sensors you can do it with a countdown timer.

1. Create a Countdown timer device. Rename it to Security timer and edit the device and set its duration to 45 seconds.
2. Create a scene. Rename it to Security light on. Set a trigger for the motion sensor An armed sensor is tripped. Add an action to Turn on the light. Add another action to Restart the Security timer (so that if the sensor trips again, the timer starts counting again from 45 seconds).
3. Create a second scene. Rename it to Security light off. Set a trigger for the Security timer Timer completes while not muted. Add an action to Turn off the light.

Probably you want to have this happen only between certain hours of the day.  Create scenes to Mute and Unmute the Security timer, and set Schedules on them to activate (unmute) or disable (mute) the security light.  Use the Heliotrope plugin to mute/unmute the timer at sunrise/set.

Offline gilles

  • Full Member
  • ***
  • Posts: 106
  • Karma: +0/-0
Re: Countdown timer plugin (UI5)
« Reply #6 on: February 11, 2012, 03:41:03 am »
Hi Futzle,

really great plugin.

Is there a way to have multiple countdown in only one countdown device.

I'm a "vera padawan", but I find that it will be usefull to concentrate functionnality to device.
In my vera I've got too many virtual devices.

Don't if I'm clear but I think it's important for the future.

Envoyé depuis mon GT-I9000

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Re: Re: Countdown timer plugin (UI5)
« Reply #7 on: February 11, 2012, 05:14:32 am »
Is there a way to have multiple countdown in only one countdown device.

It's one timer per device, on purpose. I wanted to keep the plugin as simple as possible; it's got enough of a learning curve as it is. Since you've probably got to combine it with at least three scenes to achieve anything useful, I'm hoping that users are going to get used to the clutter (our that micasaverde comes up with a better way to hide them).

Then there's the technical matter of the device buttons: multiple timers mean multiple sets of buttons, and how many sets do you stick into the static JSON file?

Edit: spelling
« Last Edit: February 11, 2012, 06:53:32 am by futzle »

Offline big517

  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-3
Re: Countdown timer plugin (UI5)
« Reply #8 on: February 11, 2012, 06:19:56 am »
Can you also add notification support for timer start and restart?
Great plugin!


Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Re: Re: Countdown timer plugin (UI5)
« Reply #9 on: February 11, 2012, 06:52:46 am »
Can you also add notification support for timer start and restart?

Sure. It would be handy to understand the intended use case, and why you can't achieve the same thing by having the thing that triggers the timer (re)start do the action itself. (I'm against adding complexity that doesn't add functionality.)

Offline big517

  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-3
Re: Countdown timer plugin (UI5)
« Reply #10 on: February 12, 2012, 07:47:31 am »
I just want to make sure it was turned on because looking at the ui in chrome, it doesn't always show it counting down even if it is..


Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Re: Countdown timer plugin (UI5)
« Reply #11 on: February 12, 2012, 03:41:02 pm »
I've submitted version 2.0 to apps.mios.com. This version has a full set of events (started, restarted, cancelled, completed) as well as events for when an action has failed (for instance, trying to start an already-started timer). There are also some other bugfixes to do with timers surviving Luup restarts.

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Re: Re: Countdown timer plugin (UI5)
« Reply #12 on: February 12, 2012, 03:44:46 pm »
I just want to make sure it was turned on because looking at the ui in chrome, it doesn't always show it counting down even if it is..

The icon is supposed to change when the timer is counting. The buttons, not so much because none of the buttons directly correspond to the state variables. I think I've seen cases where the icon hadn't updated. I'll pay extra attention if it happens again.

Offline Otje

  • Full Member
  • ***
  • Posts: 204
  • Karma: +4/-1
Re: Countdown timer plugin (UI5)
« Reply #13 on: February 12, 2012, 04:09:33 pm »
I have a question on the timer

I understand you can set a timing per device. But what if you want to have more timers like this to be used?
I can't see how I can get more then one device in Vera. I am new to Vera, maybe that explains, but how can i get more instances of this timer module, such that i can have 5mins timers, 10mins timers etc?
Do i need to install the app more then once?

thanks in advance.
VERA Plus, VERA 3 Lite , couple of PIR's, several switch units, wall mounted tablet, Sonos integration with TTS, Temperature sensors, Imperihome, Zwave LED bulbs

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3224
  • Karma: +180/-8
Countdown timer plugin (UI5)
« Reply #14 on: February 12, 2012, 05:06:24 pm »
It's well hidden in UI5.  Go to Apps > My Apps and click on the words "Countdown Timer". There's a link in the resulting dialog that makes extra instances.