At this point, all I have done is install the program logic core, program logic event generator and program logic timer switch plugins. What I’m hoping to accomplish for now is to learn how to setup a scene that turns light A on if 1) a motion sensor is tripped AND 2) light B is on.
We will use the Program Logic Event Generator plugin.
Open up the settings for the plugin and start with Inputs
Triggers is already hilighted.
To create an input trigger: Select Please Select a Device
Select the motion sensor you are interested in.
Select the event type (A Door) is tripped
Name the trigger … lets call it Motion
Repeat this for Lamp B, when it’s on call it LampBOn
[hr]
Now click on the Conditions tab
Click Add Row
Name the Condition AutoOn
Set the Condition Expression to [b]Motion and LampBOn
[hr]
Now we need to defined what we want to do when AutoOn happens.
Click the Actions tab.
Click Add Actions for Condition: AutoOn
This opens up the Scene Editor … that lets you pick the commands to execute.
Find your Lamp A and click the On button.
Then click the Finished at the top.
[hr]
The close the PLEG tab and click the Save in the upper Right Hand corner.
Have a beer … you have now started down the path of automating your home!
[hr]
You can always come back and edit Inputs, Conditions, Actions, and Notifications.
Add more conditions and actions as you wish to be more sophisticated with your logic.
SOOOOO awesome, very much appreciated Richard! Been wanting to create scenes that this plugin allows for awhile now. I’m sure I’ll have more questions come up but I’m definitely on my way now, though. Thanks again!
Well I know I’d have more questions…
Are you not able to run a Scene as an Action within PLEG? For example, if a Condition is met, turn LightA on (action #1) and run SceneB (action #2).
What’s odd is when I first select the Condition from the drop down in the Actions tab, it takes me to the list of all my devices, however, it doesn’t show any of my scenes. BUT, if I click Devices at the top left, then all of the sudden they all show up in the list below. Regardless of that issue, once I see them in the list below, it doesn’t seem to let me select any of them as an action.
Are you not able to run a Scene as an Action within PLEG?
No Because Vera has not provided the device that Run’s the scenes in the device list.
NOTE:If it existed it would be available in the Advanced Menu … That’s the only place to add actions that take a user defined option, like the Scene to Run.
I am using the same (actually a subset) of the Vera Scene code.
Vera does not provide the ability to run a scene from a scene.
I made a request for this a long time ago on the forums when I naively thought MCV was participating in the forums.
You can currently have a scene have a trigger to run the scene when PLEG has satisfied condition XXXX.
Other than a trigger the only way I know to run a scene is from LUA code or a remote HTTP request.
[hr]
But I think I will might add an action to the PLEG to run a scene … But it might not seem like the right place to find this functionality.
BUT, if I click Devices at the top left, then all of the sudden they all show up in the list below.This is a Vera Bug if you see scene's in the device list. As I said ... this is Vera Code ... So I am bug for bug compatible with them!
Ok so if I try the trigger idea, then I would set something to be a trigger for the scene (e.g. Light A is turned on), then set the action for the PLEG I’m creating to turn Light A on, there by triggering the scene? That sounding right to you?
Regardless of that issue, though, I seem to be having a problem with a PLEG I just setup. Here’s how I have it:
Inputs:
Triggers:
ArmedStay (NX-8 alarm panel armed to stay)
VacaSwitchOn (a virtual switch set to On)
Schedules:
Sched1 (Just to test it out I select today’s date and 3 or 4 minutes ahead)
Conditions:
VacaOn VacaSwitchOn and ArmedStay and Sched1
Action:
Vaca1 Turn on a light
Problem is that the light turns on at the specified time in Sched1 regardless of the ArmedStay condition in my logic. It does seem to abide by the Virtual Switch (VacaSwitchOn) condition, though (I’ve tested with alarm panel armed to stay and the Virtual Switch off and the light will not turn on at the specified time in Sched1). Any idea why it’s not abiding by the ArmedStay condition?
Also, something that’s weird is that even with the PLEG plugin Bypassed, when I toggle the Virtual Switch to On it triggers the light I have specified as the Action for the PLEG. Any idea why that is?
Say you have a PLEG named PrevalentTheory with a condition called the BigBang and you would like to run the scene UniverseIsFormed when the BigBang is triggered.
Since you can’t run a scene from an Action. You can add a trigger to the UniverseIsFormed scene for the PrevalentTheory device when it has has satisfied the BingBang condition.
Also, something that's weird is that even with the PLEG plugin Bypassed, when I toggle the Virtual Switch to On it triggers the light I have specified as the Action for the PLEG. Any idea why that is?Currently you can only trigger on the action satisfied. I also have event for Action Satisified and PLEG armed ... This latter event does not work because of a bug in Vera. They fixed half of the problem in the last release ... It has been listed as a Vera defect on my Website for 6 months. I will post a fix (for a Vera File) in the forums in the next few weeks.
[quote=“RichardTSchaefer, post:7, topic:174998”]Say you have a PLEG named PrevalentTheory with a condition called the BigBang and you would like to run the scene UniverseIsFormed when the BigBang is triggered.
Since you can’t run a scene from an Action. You can add a trigger to the UniverseIsFormed scene for the PrevalentTheory device when it has has satisfied the BingBang condition.[/quote]
In the beginning, there was PLEG. 8)
My compliments to Richard Schaefer. Simply ingenious work you’ve done with PLEG. I’m a bit of a newbie, and am trying to figure out how to use PLEG. I would like to use PLEG to create a Lamp Toggle, where PLEG can turn the light on if its off, or off its on. trigger from a remote control button. Attempts to get PLEG to do this so far have failed.
Triggers
Name Description
t1 Office/Music Remote: scene number 3 is activated
Schedules
Name Type Time Days
Device Properties
Name Device Name Device Variable
LampStatus Office Lamp Status
Conditions
Name Expression
LampOff_to_on t1 and LampStatus eq “0”
Actions
Actions for Condition: LampOff_to_on
Device Action Arguments
Office Lamp SetTarget newTargetValue=1
the above turns the lamp on from off, however, if I try to turn the lamp off from the Devices panel, the light goes off, and then immediately on again; it seems like PLEG is trying to enforce the conditions continually, not just momentarily when executed. I have to put PLEG on bypass in order to shut the lamp down. Any advice/admonishments as to what I’m doing wrong?
kind regards
That expression is evaluate every time T1 is turned on and LampStatus is changed.
That’s why there it appears to always be true. If your Music remote was momentary it would fail when the LampStatus is changed manually at a later time. Apparently it stays in the Selected state.
Maybe try:
LampOff_to_on (LampStatus;t1) and (LampStatus eq “0”)
Which basically says t1 has to happen after the last LampStatus change in order to be true. So only t1 can cause it to toggle On, but only when the lamp is also currently off.