Countdown plugin Lua functions

Is there any way to trigger the countdown timer plugin’s Lua functions using scripts? I’ve searched and found ways to query the variables, but I’d like to be able to build a script that uses the plugin’s functions (ie.-restart timer, stop timer, etc.) without having to click the buttons and I’d rather avoid having tons of scenes to accomplish one task or have to learn PLEG (no matter how excellent I’ve heard it is) just to accomplish a few simple tasks.
Thanks in advance.

PLEG is not that hard to learn. I have been expanding my use of it since December. For instance, my scene to turn on exterior lights now uses weather information. If it is raining, turn them on 30 min before sunset, and off 30 after sunset. If overcast, 15 min. If clear, on at sunset, off at sunrise. This would be very complicated using scenes.

I don’t doubt the power of PLEG, but can’t that all be done with Lua?
Honestly, I’m trying to avoid investing my time in learning yet another proprietary “language” since I’ve bounced around from technology to technology a fair bit and wasted years of my life learning how to use stuff that I’ve eventually moved away from. The Vera is pretty good, but there will surely be other potential solutions in the future that might be even better. Lua has the advantage of being used all over the place. The way I see it, I can learn an obscure language that I will never use except to speak to one woman that I decide to date, or I can learn French or Spanish and open up my options. :wink:

Look in the I_CountdownTimer1.xml file where you’ll see the action list. You’ll see items such as “RestartTimer”. So I think you can do this (I have not tested it):

luup.call_action(“urn:futzle-com:serviceId:CountdownTimer1”,“RestartTimer”,{},dID)

where dID is your device ID for the timer.

Found this post (http://forum.micasaverde.com/index.php/topic,9425.msg70493.html#msg70493) from futzle:

– Actions are: StartTimer, RestartTimer, CancelTimer, ForceComplete
luup.call_action(“urn:futzle-com:serviceId:CountdownTimer1”, “RestartTimer”, {}, deviceId)

PLEG is LUA - just a simple interface, not a language. You enter schedules, perhaps look at device variables, or even a trigger. You create your conditions, and fire your logic action based on those conditions. Personally, I do not have time to learn LUA.

jswim788 - Thanks! That’s exactly what I was looking for. I’ll give it a go.

Don, I’ve looked at the PLEG document in the past and it looked like it had a bit of a learning curve. Maybe I’ll take another look at in sometime in the future when I’m feeling more motivated/energetic. Lua is pretty complicated as well, but it’s very powerful and used in everything from automation to video games. Definitely very versatile.

Hello everyone,

is it possible to trigger with lua via variable watch? I was not able to get a stable “countdown ends” trigger…

Jens

What are you running this on?
If you are running it on a machine which is too fast, the luup engine will miss the trigger because the variable change back and forth is too fast for the engine to detect it.
I created a fix for it here:

1 Like

Hi,

I’m running it on a vera plus. This was exactly the program. I will have a look into it, because these are the only scenes running the original script thing from vera, and not via lua.

Thanks!

edit: Do I just replace the files in the luup files section? What are the lua commands for the triggers?

edit2: Is this the important section:

luup.variable_set(ServiceId, “Event”, 1, Device) – 1 = complete

and the delay after it? So I should just watch the “event” section and get a “1”?

Yes just replace the one luup file I changed actually. It will be sufficient to just upload L_CountdownTimer1.lua

I think the plugin was written for much older veras and is not quite as reliable on the faster units.

What I do is just run a variable watch on the “event” variable and indeed trigger when it is set to 1.

1 Like

Great thank you very much! I will give it a try!