Countdown timer plugin (UI5)

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.

Scenarios using the Countdown timer plugin:

[ul][li]Turn off a light after 5 minutes[/li]
[li]DIY alarm entry delay[/li]
[li]Automatic security light[/li]
[li]Bathroom occupancy light[/li][/ul]

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.

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

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.

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.

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 avec Tapatalk

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

Can you also add notification support for timer start and restart?
Great plugin!

Sent from my SPH-D710 using Tapatalk

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.)

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…

Sent from my SPH-D710 using Tapatalk

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.

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.

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.

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.

:slight_smile: i found it.
Indeed, well hidden in UI5.

Thanks alot for your help.

Is there a way to NOT execute a scene, but still restart timer if the Timer is currently COUNTING DOWN?

For instance, I have my living room setup to turn ON lights when someone enters and the Motion sensor is ARMED, then to turn OFF lights if there is NO Motion Trigger within 30 minutes (using this timer)

1 Scene to TURN ON LIGHTS AND START / RESTART TIMER when occupancy is detected
2 Scene to TURN OFF LIGHTS WHEN TIMER IS COMPLETE

I don’t want to stop the timer, but I want control of the lights in that room while the timer is counting down…
So while the room is occupied I can change the lights that were turned on with the motion trigger, however my problem is that the motion trigger keeps firing and resetting the lights which is the unwanted side effect.

I was thinking about adding LUUP to the TRIGGER portion to RESTART the timer, but NOT Execute the scene if the timer is active, and the only way I could figure this to work is if the timer is currently counting down. This will allow the scene to still turn the lights on immediately when someone walks into the room initially (counter was not running), and allow them to adjust the lights and occupancy keeps resetting the timer so it will still turn off the lights after the timer completes. however I’m not sure how to accomplish this other than my idea above which requires LUUP Code, can someone help with this?

Is this even the best way to structure this?

Thank you,

Interesting scenario. Here are a couple of ideas.

From version 2.0 the plugin has new events, “timer is started” and “timer is restarted”. These fire, respectively, when the timer hadn’t previously been running, and when it was already running. In your case, attach the Lights On action to a new scene that is triggered by the “timer is started” event, instead of to the motion sensor detection scene.

To summarize:

Scene A: triggered by motion sensor; sends Restart to timer.
Scene B: triggered by timer start; sends On to light.
Scene C: triggered by timer complete; sends Off to light.

Something else you might want to mess with is muting. You can add a scene triggered by the light being turned off, that mutes the timer so that its events don’t fire. This is a more extreme form of manual control, and you’d likely want to make a scene that unmutes the timer later to reset the automation. Naturally, you can use another Countdown Timer for that…

That sounds good. I’ll give that a shot.

Thanks again for this plugin.

Sent from my SPH-D710 using Tapatalk

I noticed something strange when using the timer in scenes.
I create a scene and via a trigger I have the timer restarted, see image below.
Later on when I edit the scene and go to the timer device i do not see the box and red cross anymore, indicating that the trigger is going to restart the timer. Normally i can see it for other devices, but not when I use the timer.

is this normal?