We have moved at community.getvera.com

Author Topic: Why use the Program Logic Plugins ?  (Read 13576 times)

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Why use the Program Logic Plugins ?
« on: February 23, 2013, 02:32:37 pm »
When you first try to customize your Home Automation system you will start by writing a scene.

The Scene might be to turn on a light.

Next you might trigger this Scene to when there is motion in the house (Motion1) or an exterior door is opened (DoorOpen2).

Next you decide you want the light to only come on if it's dark outside.

 :o You have just stepped into the advanced developer scenario defined by Vera :o

Vera only supports the Logical OR of its input triggers.
They easily supported: Motion1 or DoorOpen2
But they consider:  (Motion1 or DoorOpen2) AND Dark3
or just (Motion1 AND Dark3) as an advanced user feature.
And Vera recommends to solve this you must use LUA code (which is a scripting language), Vera's extensions (LUUP functions), and know about UPNP naming to find the device variables in Vera you want to use to drive your advanced logic.

 ??? Have I lost you yet ???

The Program Logic Event Generator and Program Logic Timer Switch plugins were developed to:
  • Allow you to use the Browser User interface to find/create the inputs to your logic and assign them user friendly names.
    Inputs can be the trigger from any device in Vera, The value of any device variable in Vera, and/or scheduled timers, similar to those available to trigger a scene.
  • Use your user friendly input names to create very sophisticated logic expressions called conditions.
    Each condition also has a user friendly name, and utilizes boolean, numeric, string, and sequence of inputs events operators to combine the inputs and other conditions to define your logic.
  • Use the Web Browser to attach a different set of device commands, called Actions for each condition.
    This is very similar to how you add device commands to a scene.
Why is the the last point important ...  Without the PLEG, or PLTS plugins,  Vera would require one scene to turn on the light, and a second scene to turn off the light. Each with their own triggers and logic.
This allows you to consolidate all the pieces for a logical component in one place. Makes it much easier to understand your logic and modify it in the future.

You can control multiple devices with a single PLEG device ... just add more condition variables and associated actions.

You still have to be able to express your problem in a logic expression. But you do not have to learn the low level syntax and semantics of LUA/LUUP.

Create a new topic if you want to discuss how to utilize the PLEG and PLTS plugins to solve your particular problem.


« Last Edit: February 23, 2013, 02:59:55 pm by RichardTSchaefer »

Offline Pestus

  • Full Member
  • ***
  • Posts: 122
  • Karma: +2/-0
Re: Why use the Program Logic Plugins ?
« Reply #1 on: March 30, 2013, 11:55:46 am »
Thank you thank you!

Without this, the Vera doesn't live up to it's potential!  Micasaverde ought to include your work into the design!

Still struggling to understand the basics, but if I can figure out your work, I'll be a happy camper indeed.

Offline gerardosamara

  • Full Member
  • ***
  • Posts: 200
  • Karma: +5/-2
Re: Why use the Program Logic Plugins ?
« Reply #2 on: July 06, 2013, 05:19:30 am »
Starting to look at these PLEGS and PLTS plugins in order to understand when/how  to use them.

It would help newbies to describe separately the description of each plugin  :D
« Last Edit: July 06, 2013, 05:23:19 am by bottrader »
VeraLite+VeraEdge/EnOcean version US en UI7.1.17 + Vera Mobile UI7 V7.15.17.40 + Imperihome pro V2.8.3
Wall switch : Leviton VRS15 , Smart switch : Aeotec DSC24 , Motion sensor : Aeotec 4in1 DSB05 + Everspring HSP02 , Cameras Dlink 742L + Foscam 8910 + Foscam 9853EP

Offline garrettwp

  • Master Member
  • *******
  • Posts: 6371
  • Karma: +227/-128
  • Vera 3, Lite, ISY994
Re: Why use the Program Logic Plugins ?
« Reply #3 on: July 06, 2013, 05:25:02 am »

Offline pdoughty

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Why use the Program Logic Plugins ?
« Reply #4 on: November 28, 2013, 11:47:54 am »
Hello Richard,

Thanks for your reply. Is there a manual for Vera for basics?
Also, I've seen other posts to keep off lights when is "DAY". Any idea what's the simplist way t o get it done? Can the DAY/Night plugin disable devices?

I have a lot of questions and normally would be reading manuals: I just don't know if they exist.

Thanks,
Paul

Offline johnes

  • Hero Member
  • *****
  • Posts: 630
  • Karma: +7/-7
Re: Why use the Program Logic Plugins ?
« Reply #5 on: February 05, 2014, 03:28:59 am »
In PLEG, this would turn on lights at night...
So you can use this example to do one to turn off at night.

setup a Input>Trigger for the Day/Night plugin that detects Night, call it IsNight.

Condition:
LivingRoomLight_TurnOn
IsNight and !LivingRoom_LightOn

Action:
LivingRoomLight_TurnOn: Select your light

Or you can make a schedule (BedtimeToSunrise) for example... then create a condition and put this in it:
BedtimeToSunrise

The create an action based on that.

Offline A.Ardon

  • Full Member
  • ***
  • Posts: 113
  • Karma: +0/-2
Re: Why use the Program Logic Plugins ?
« Reply #6 on: February 05, 2014, 06:28:34 am »
I only think:

Why NOT use the Program Logic Plugins ? ;D
1x VeraPlus UI7, Opentherm- Gateway, Powermax+,  Philips Hue, Dahua DVR, Yamaha RXV775, ect.

Offline hamishb

  • Sr. Newbie
  • *
  • Posts: 22
  • Karma: +1/-0
Re: Why use the Program Logic Plugins ?
« Reply #7 on: February 05, 2014, 07:37:18 am »
Looks terrific. Are there any screen shots or screencasts I could look at?

Offline cubs2b23

  • Full Member
  • ***
  • Posts: 102
  • Karma: +2/-0
Re: Why use the Program Logic Plugins ?
« Reply #8 on: February 05, 2014, 09:19:15 am »
In PLEG, this would turn on lights at night...
So you can use this example to do one to turn off at night.

setup a Input>Trigger for the Day/Night plugin that detects Night, call it IsNight.

Condition:
LivingRoomLight_TurnOn
IsNight and !LivingRoom_LightOn

Action:
LivingRoomLight_TurnOn: Select your light

Or you can make a schedule (BedtimeToSunrise) for example... then create a condition and put this in it:
BedtimeToSunrise

The create an action based on that.

I tried doing something similar. Do I have to create a second condition so that the light turns off at the end of the schedule?

Offline BulldogLowell

  • Hero Member
  • *****
  • Posts: 1576
  • Karma: +191/-85
Re: Why use the Program Logic Plugins ?
« Reply #9 on: February 05, 2014, 09:24:57 am »
For this very simple (Sunset to Sunrise) routine, you can just use a scene.

But to answer your question, your PLEG will have two conditions:

IsNight
Not IsNight (!IsNight)

You will then have two actions.  One that turns on the light (IsNight) and one that turns it off (Not IsNight).

So, yes you need tow conditions, because you will trigger the light On/Off with the change of the IsNight trigger.

Offline cubs2b23

  • Full Member
  • ***
  • Posts: 102
  • Karma: +2/-0
Re: Why use the Program Logic Plugins ?
« Reply #10 on: February 05, 2014, 09:34:53 am »
I currently have a couple lights that turn on with scenes 1) ON at sunset and 2) Off at 10:00 pm.  I was trying to learn more about PLEG and how the schedules could be used to do the same thing. So I tried a quick example using a set 5 minute time.

Code: [Select]
Schedules
Name        Type        Time         Days                 Random On Delay Off After Type Off Time          Off Days         Random Off Delay
SLights_On Weekly 13:15:00 1,2,3,4,5,6,7 None                   Weekly           13:20:00 1,2,3,4,5,6,7 None

Conditions
Name Expression
CLights_On SLights_On

Actions
Actions for Condition: CLights_On
Immediate
Device Action Arguments
Garage Light SetTarget newTargetValue=1

So do I need a second condition that just says
Code: [Select]
!SLights_On ?

Offline RichardTSchaefer

  • Moderator
  • Master Member
  • *****
  • Posts: 10091
  • Karma: +764/-143
Re: Why use the Program Logic Plugins ?
« Reply #11 on: February 05, 2014, 09:42:31 am »
You have two choices:
1) Add anotjer condition as you indicate with the appropriate action.
2) Modify your action ... use the Advanced tab and change the 1  as the SetTarget argument to:

{(SLights_On ? "1" : "0")}