We have moved at community.getvera.com

Author Topic: Program Logic Event Generator Plugin  (Read 433832 times)

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Program Logic Event Generator Plugin
« on: December 04, 2012, 09:01:38 am »
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:
  • Inputs
    You provide a name to each of the following inputs you choose to use:
    • Triggers - Similar to Scene Triggers
    • Schedules - Similar to Scene Schedules
    • Device Properties - Any Device Property can be a trigger
  • Conditions
    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.
    • 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.

  • Actions
    • Output Triggers
      • When PLEG has satisfied condition XXX
      • 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.
    • Notifications
      Just like any other Vera Device.
    • Actions
      This will be in the next release. This equivalent to the Device and Advanced tab of a Scene ... only better!
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:http://RTS-Services.com/Vera/Plugin/PLEG
« Last Edit: February 23, 2013, 03:06:19 pm by RichardTSchaefer »

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: NEW: Program Logic Event Generator Plugin
« Reply #1 on: December 04, 2012, 04:11:53 pm »
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.

Offline S-F

  • Hero Member
  • *****
  • Posts: 1248
  • Karma: +62/-12
  • Clueless N00b
Re: NEW: Program Logic Event Generator Plugin
« Reply #2 on: December 04, 2012, 06:23:22 pm »
Sir, if I wore a hat, it would be off to you.

I second this statement!

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 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.
My forum account was apparently hacked by a leprechaun. And he's drunk all of the time. If a post of mine seems a little off kilter, it's probably because he made it.

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #3 on: December 04, 2012, 07:48:49 pm »
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:
  • 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.
  • 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.
  • To be able to use other Condition Expressions Names like trigger names in Condition Expression

Offline markbannister

  • Full Member
  • ***
  • Posts: 113
  • Karma: +1/-0
Re: NEW: Program Logic Event Generator Plugin
« Reply #4 on: December 05, 2012, 10:28:29 am »
Just saw this today!  Wonderful stuff!
I'll play with it over the holidays.

Offline lvs

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: NEW: Program Logic Event Generator Plugin
« Reply #5 on: December 07, 2012, 11:11:06 am »
Richard,

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.

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #6 on: December 07, 2012, 11:22:41 am »
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

Offline lvs

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: NEW: Program Logic Event Generator Plugin
« Reply #7 on: December 07, 2012, 11:35:10 am »
^ Much appreciated Richard!

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #8 on: December 13, 2012, 07:46:34 am »
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!.



Offline S-F

  • Hero Member
  • *****
  • Posts: 1248
  • Karma: +62/-12
  • Clueless N00b
Re: NEW: Program Logic Event Generator Plugin
« Reply #9 on: December 22, 2012, 06:33:28 pm »
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.
My forum account was apparently hacked by a leprechaun. And he's drunk all of the time. If a post of mine seems a little off kilter, it's probably because he made it.

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #10 on: December 27, 2012, 03:43:53 pm »
A couple of people seem to have problems downloading this APP. It appears to be a problem on the apps.mios.com 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:
Code: [Select]
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
  <specVersion>
    <major>1</major>
    <minor>0</minor>
  </specVersion>
  <device>
    <deviceType>urn:schemas-rts-services-com:device:ProgramLogicEG:1</deviceType>
    <staticJson>D_ProgramLogicEG.json</staticJson>
    <serviceList>
      <service>
        <serviceType>urn:schemas-rts-services-com:service:ProgramLogicEG:1</serviceType>
        <serviceId>urn:rts-services-com:serviceId:ProgramLogicEG</serviceId>
        <SCPDURL>S_ProgramLogicEG.xml</SCPDURL>
      </service>
      <service>
        <serviceType>urn:schemas-rts-services-com:service:ProgramLogicC:1</serviceType>
        <serviceId>urn:rts-services-com:serviceId:ProgramLogicC</serviceId>
        <SCPDURL>S_ProgramLogicC.xml</SCPDURL>
      </service>
    </serviceList>
    <implementationList>
      <implementationFile>I_ProgramLogicEG.xml</implementationFile>
    </implementationList>
  </device>
</root>
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.

Offline S-F

  • Hero Member
  • *****
  • Posts: 1248
  • Karma: +62/-12
  • Clueless N00b
Re: NEW: Program Logic Event Generator Plugin
« Reply #11 on: December 29, 2012, 09:03:25 am »
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: http://forum.micasaverde.com/index.php/topic,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?
« Last Edit: December 29, 2012, 09:09:23 am by S-F »
My forum account was apparently hacked by a leprechaun. And he's drunk all of the time. If a post of mine seems a little off kilter, it's probably because he made it.

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #12 on: December 29, 2012, 11:11:21 am »
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

Conditions:
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.


 

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #13 on: January 04, 2013, 08:50:54 pm »
I have updated the documentation with some examples:
See: http://rts-services.com/Vera/Plugin/PLEG/#Usage
The current examples include:
  • Two State Switch - Normal and Timed Off - Based on Double click of switch
  • All Quite - Run UnOccupued - Many Motion Sensors and a Exit Door Sensor
  • Sleep In - Google Calendar, Bed Sensor, Vera Alerts
  • Simulate Smart Switch Behavior - You Need a Motion Sensor, Switch, On and Off Scene

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: NEW: Program Logic Event Generator Plugin
« Reply #14 on: January 12, 2013, 11:36:05 am »
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.