Use LUA to call PLEG timer in UI7?

Hi. I am using UI7 and I am stuck creating an action in PLEG. I’d like to add a PLEG action to start a timer. Because there is no action builder in the UI7 gui I need to execute this action using LUA. So my question is, how do I write LUA to do this:

KeepOn: PLEG StartTimer timerName=Timer

Thanks for any pointers

Have you seen this thread?

After setting/selecting Immediate, select Advanced to create the Action to start the timer.

Thank you Rex. I had overlooked that thread. Easily solved.

I got same issue here… can someone point out how to create the PLEG Starttimer using LUA in UI7?

many thanks

[quote=“sapiloncat, post:4, topic:185200”]I got same issue here… can someone point out how to create the PLEG Starttimer using LUA in UI7?

many thanks[/quote]

Do you really want the Lua code to start a PLEG timer or do you need instructions for using PLEG’s Advanced action editor?

If the former, the code is:

luup.call_action("urn:rts-services-com:serviceId:ProgramLogicC","StartTimer",{timerName=<timer> ,intervalTime=<interval> },123)

Where is the name of the PLEG Schedule, is the interval time required and 123 is the device number of PLEG. If you don’t specify an interval, the default one from the Schedule will be used.

Hi Rex,

thanks for the LUA code.

I use your PLEG Basics as my guide for PLEG… great manual.
if you can continue with PLEG Advance manual (include PLEG LUA script) it will be AWESOME.

thanks for your great effort

agus

[quote=“sapiloncat, post:6, topic:185200”]Hi Rex,

thanks for the LUA code.

I use your PLEG Basics as my guide for PLEG… great manual.
if you can continue with PLEG Advance manual (include PLEG LUA script) it will be AWESOME.

thanks for your great effort

agus[/quote]

Thanks for the feedback, @sapiloncat. Is there scope for an Advanced PLEG guide?

The majority of automation logic can be implemented using PLEG Conditions and Actions. It is only quite specialized applications that need additional Lua code. Examples in my system are logging temperature values to a file and starting/stopped camera recording on the Synology NAS.

Lua code runs in PLEG very much like it does in a Vera scene. It doesn’t have access to Vera’s Startup Lua context but PLEG provides an alternative. It also has access to PLEG Inputs and Conditions using the special syntax described in PLEG Basics. With those exceptions, there is nothing special about using Lua in PLEG.

What aspects are giving you problems?

Hi there

I am a newbie at PLEG and have decided to take the plunge into PLEG as its something i have been watching for while. After my Veralite gave up with the constant issues with memory and restarts i have moved over to the Vera Edge

Currently i have my Downstairs PIR set at 2 minutes in triggered state then it resets.

Moving around the Vera UI7 has been a challenge but that’s the hand i have been delt. I used the example from the PLEG BASICS which is a really good intro to PLEG thank you.

The issue is that the trigger fires and the lights come on (using a qubino twin relay) so it fires the fan and light as i have selected the master switch it switches both relays on FAN/LIGHT but never switches them off.

In the control section Startup LUA seems to nver do anything i just get the waiting symbol.

I have attached the status output, does this seem right as i am not sure if this is an issue with the Vera software as a number of things don’t seem quite right.

@RexBeckett and/or Richard,
Question to you in regards to timers (schedule). if I setup a single timer for a 5 minute retrigger and refer to the same timer for two different conditions how does the timer work e.g.

[ol][li]Scenario #1 Does it start on the first condition that meets it condition whilst the second condition is meet during the 5 minutes does it use the same count down value from the first condition say it the second condition was triggered at the 3 minute mark therefore the second condition has only two minutes on the timer or
[/li][li]Scenario #2 Does the second event start another instance of the timer and starts at 5 minutes and counts down? [/li][/ol]

The reason I’m asking is that if the timer behaves like scenario #1 then I will have to create multiple timers for multiple conditions needing 5 minute timers. What got me to start thinking about this is I had seen an example catering to scenario #1 with multiple 5 minute timers for multiple conditions (motion sensors and lights). Mike

Bump!

If you want two independent timers running at the same time … you need two different named timers!

Richard, thanxs for the comeback, I had my suspicions that I would need individual times. I had seen an example where the time interval value for a single timer was changed to multiple times depending on a condition, obviously it is being used singularly and not for multiple conditions. Mike

When you define a timer it has a default value … when you actually trigger a timer you can use the default or override it with a value specific to that action.