Program Logic Event Generator Plugin

The control logic available to a Vera user in a scene is quite limited. In the past this has forced many to have to use LUUP code and work with obscure UPnP ServiceIDs and Vera DeviceIds. Often to question why they have an automation system.

The Program Logic Event Generator or PLEG provides a much easier process to handle the typical scenarios that Vera can’t.

PLEG uses the same style of interface as Vera does for Scenes. (Much of the same code).
There is a separate tab for each of it’s major configuration tasks:

You provide a name to each of the following inputs you choose to use:

[li]Triggers - Similar to Scene Triggers[/li]
[li]Schedules - Similar to Scene Schedules[/li]
[li]Device Properties - Any Device Property can be a trigger[/li]
This is where you put your control logic. It references the named inputs. The Sequence expressions are the most obscure … but also the most powerful construct. Logical And, Or, Not, math, and string operations and comparisons are provided.[/li]

  • Sequence Expression - Cause an Action if a particular sequence of events happen. It can also be used to detect the absence of an event and cause a timeout behavior to happen.
  • The ability to have counted triggers … Where you only need a minimum N of the available M triggers to be true. This is similar to the Combination plugin.
  • Counted Triggers, Conditions, or Property Changes. Logic to handle too many or not enough of a particular event in the specified time. You can use the toggling of a light switch On Off On as a trigger for your logic.


[li]Output Triggers

[li]When PLEG has satisfied condition XXX[/li]
[li]When PLEG has satisfied condition XXX and state is Armed or NotArmed
The latter is not working right now because of a Vera bug. A fix was sent to MCV.[/li]
Just like any other Vera Device.[/li]
This will be in the next release. This equivalent to the Device and Advanced tab of a Scene … only better![/li]

I expect there will be problems mapping a problem to the appropriate control logic. I have provided some examples on the web site and am willing to help if you provide your scenario.

This plugin shares common code with the Program Logic Timer Switch plugin … you will need to install the Program Logic Core Plugin to obtain the shared functionality.
Documentation can be found at:

Sir, if I wore a hat, it would be off to you.

To encourage adoption, it’d be good if users could post some scenarios of real-world uses for the plugin.

I hope you don’t create a support nightmare for yourself.

I second this statement!

[quote=“futzle, post:2, topic:173496”]To encourage adoption, it’d be good if users could post some scenarios of real-world uses for the plugin.

I hope you don’t create a support nightmare for yourself.[/quote]

I second this as well. The main reason I haven’t tinkered with this or the Program Logic Event Generator Plugin is that I don’t have enough time or understanding to get it up and running. I’d need to begin to wrap my head around how these work before jumping in with both feet.

Thanks for the positive feedback … I have started to collect scenarios for the Program Logic Timer Switch. I will do the same for this.
As people ask questions I will add to the scenarios.

I also have a few more ideas to add:

[ul][li]Ability to specify ABSOLUTE Time in the Sequence expressions.
i.e. 8:00:00; DoorOpen; 16:00:00
Trigger if the door opens between the specified times.[/li]
[li]Ability to specify CURRENT Time in a Sequence expression.
i.e. SomeEvent;NOW > 1:00:00
To trigger after a specified interval from an existing event. In combination with some other boolean expression can be used as a timeout. [/li]
[li]To be able to use other Condition Expressions Names like trigger names in Condition Expression[/li][/ul]

Just saw this today! Wonderful stuff!
I’ll play with it over the holidays.


Thanks for the plugin but I am fairly new to micasaverde and am struggling with setting this up. I added this plugin and Program Core Logic plugin. Here is what I want to do. I have a door sensor and when the door is opened I want the lights to come on between two times for example between 11:00 PM and 5:00 AM. Can you provide me with a bit of assistance? Thanks.

If you check the Program Logic Core documentation or earlier in this post you will see I added a new feature request to be able to schedule using absolute times. Not done yet.

But I just released (available in the APP store) the Day or Night Plugin and you can use this to address your needs.
You can create a trigger:
NIGHT = Day or Night indicates Night
DOOR = Door is tripped

Then the condition would be:
LightsON = NIGHT and DOOR

^ Much appreciated Richard!

I have upgraded the Program Logic Event Generator and the shared plugin Program Logic Core
I now have support for absolute times in the sequence expressions.
So you can write condition expressions like:

   DayEntry = 08:00:00;DoorOpen;20:00:00 
   NightEntry =    (DoorOpen;08:00:00) or (20:00:00; DoorOpen)

Also I have support for the keyword NOW for the sequence expressions.
GarageLeftOpen = GarageClosed;GarageOpened;NOW > 30:00

If you leave the garage open for greater than 30 minutes this will trigger.

In addition to triggers you can now specify and use schedule variables in your condition expressions. A UI similar to that for schedules for a scene is provided. It has smart startup logic so that if you create an interval timer at a period of 15 minutes … it WILL run on the hour and every 15 minutes, even it Vera reboots!.

One thing that would take this plugin to the stratosphere would be the ability to have it run a scene. Maybe with a drop down list of available scenes. I have to be honest in that I don’t fully understand the workings on PLEG yet and maybe there is a way to do this currently.

A couple of people seem to have problems downloading this APP. It appears to be a problem on the site. Those that installed an earlier version do not have the problem.
If your are having problems try the following:

Create a file called D_ProgramLogicEG.xml with the following content:

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">

Then goto Apps -> Develop Apps -> Luup Files.
Where it says Uload Files select the file you created.
Then Go
Then install the Program Logic Core and Program Logic Event Generator plugin.
I will have to get @MCFlorin to find out why the file is not downloading.

Good morning.
I’m having a bear of a time trying to make my lights not come on and have Vera Alerts not yell at me if I don’t have to work. See thread:,12472.0.html
I’m wondering if this plugin could help me?
Here’s the situation. I have a scene which runs every morning to start a wakeup ramp and two timers. I have a google calendar switch which looks for a “No Work” entry. I can get wakeupramp to not run when the switch is tripped but the timers still run. Can I use PLEG to only run my wakeup scene if the switch isn’t tripped?

Yes, PLEG is quite flexible. I am sure It can handle this scenario.

With PLEG create:

Trigger: SleepIn - When Google Calendar Indicates No Work
InBed - Bed Occupancy detects you sleeping

Calendar: WakeTime - Schedule the times to Trigger the Wakeup
AlertInterval - Repeat Interval for alert messages

StartRamp = WakeTime and InBed and (NOT SleepIn)
Alert = StartRamp And AlertInterval
NastyAlert = InBed and (InBed;StartRamp > 15:00)

Add a Notification in PLEG when condition Alert is satisfied.
Add another Notification in PLEG when condition NastyAlert is satisfied.

Then you have a scene to start your ramp using a trigger of PLEG has Satisfied StartRamp.

Save … Then in in VeraAlerts override the default alert messages for the above Notifications to specify tone and/or tts and appropriate scolding text.

I have updated the documentation with some examples:
The current examples include:

[ul][li]Two State Switch - Normal and Timed Off - Based on Double click of switch[/li]
[li]All Quite - Run UnOccupued - Many Motion Sensors and a Exit Door Sensor[/li]
[li]Sleep In - Google Calendar, Bed Sensor, Vera Alerts[/li]
[li]Simulate Smart Switch Behavior - You Need a Motion Sensor, Switch, On and Off Scene[/li][/ul]

There is a bug in PLEG when you use a condition variable in a condition expression.
It indicates you have a syntax error. In some cases it still works correctly.

Loading the following file will fix the problem. I have a new version coming out soon.
It has some more new features … and this fix will be included.

Hi There, I am having an issue with the Program Logic Event Generator Plugin
When I click the Trigger Tab, no triggers are shown
Opening pleg_Triggers…

Any help will be appreciated.

Did you install the Program Logic Core Plugin as well ?
Should be a warning message on the top of the web page.

If you did what version are your running ?
Are you using the Beta ?

Hi RichardTSchaefer,

After a few reloads, I can see the triggers.

Thanks for your quick response.

PLEG has been updated. You can now bind any Vera Device Property to an input that can be used in your condition expressions. Also support for math and string operations and comparisons have been provided. The web documentation has been updated. The first entry in this thread has been updated to reflect the current state of the plugin and provide a road map of what’s next.

To Update Program Logic Timer Switch

To Update Program Logic Event Generator

To Update Program Logic Core

You should wait for Vera to restart between each update.

[quote=“RichardTSchaefer, post:9, topic:173496”]Also I have support for the keyword NOW for the sequence expressions.
GarageLeftOpen = GarageClosed;GarageOpened;NOW > 30:00

If you leave the garage open for greater than 30 minutes this will trigger.



thanks for your job
i want to realyze a scene with a prowl notification if my garage door is open > 30 min
i have 2 door
I make 1 condition for each door but i don’t understand the varaibal garageClosed and GarageOpened
i want to use a sm103 to know if my door is tripped or not

thanks for your help

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules