PLEG Basics - An Introduction to the Program Logic Event Generator

1. when creating the schedule "IsMorning", I do this within PLEG, correct?
Exactly. You do this on PLEG's [b]Schedules[/b] tab.
Then for the triggers... in PLEG, I have to select a device before I can create a trigger. So, for LightOn, what device would I select? the light I want in the scene?
Correct. The reason for having this Trigger is to avoid turning on the light if it is already on. It isn't that it would break anything but it is generally good practice to avoid unnecessary commands.
If it's more than one light, do I create a trigger for each light?
That is slightly more difficult. If you are going to control each light separately, you would want a Trigger for each one. If you plan to turn them on or off as a group, you could use the state of a single light to represent them all. The question to ask yourself is: If one light is already on, do I want to turn the others on or not?
3. Similar... what device do I select when creating a trigger for IsMorning?
[b]IsMorning[/b] will be a Schedule so you don't need to create a Trigger for it.

Thanks… OK, I think I have this setup, but it’s still not working. Attached is a screen shot for the Status page. I set the time for 30 minutes before/after the actual time to test.

see any glaring screw-ups?

Also, when I created the two triggers, it added “1” to the end of each? why?

Lastly, when trying to type in the condition expression in the dialog box, nothing would type at first… meaning i’d type but nothing would input into the box. I’d have to click around a bit to get it to work. thoughts?

Happy to pay/register if that’s what’s going on here. Was going to anyway… but just trying to get this one to work first.

Thanks.

PS. I’m confused about arm/bypass, although I tried it with each.

I set the time for 30 minutes before/after the actual time to test.
When you create a new Schedule, it will not get synchronized to the current time until the start-time occurs. You can force it to be true by clicking the [b]Do It Now[/b] button.
Also, when I created the two triggers, it added "1" to the end of each? why?
PLEG thinks that you already created Triggers with those names. If you did so but then deleted them, you need to refresh your browser page before trying to reuse the names.
Lastly, when trying to type in the condition expression in the dialog box, nothing would type at first.... meaning i'd type but nothing would input into the box. I'd have to click around a bit to get it to work. thoughts?
Sometimes the first click terminates the edit of the field you were in - like the Condition name. A second click in the expression field should then allow you to enter your expression.
PS. I'm confused about arm/bypass, although I tried it with each.
If PLEG is not Armed, the Actions will not be executed. Conditions will be evaluated either way and the Status report will show the current state.

Thanks Rex… I think i’m starting to get this, at least in my head. But it still doesn’t work.

I actually deleted the device, then reinstalled from my apps tab. (clicked on create another on the PLEG link in the installed apps)

Recreated all the triggers/conditions/schedules/actions per the original instructions from BullDog.

Clicked the “do it now” button to sync time. And still no joy.

Weirdly now, when I try to click on report or status, nothing happens. Guessing I screwed something up even more when I deleted the device? Should I have done something with PLC as well?

Weirdly now, when I try to click on report or status, nothing happens. Guessing I screwed something up even more when I deleted the device?
That situation can often be fixed by refreshing the browser page but in your case...
Should I have done something with PLC as well?
There was a recent issue with the order of installation. I thought it was fixed now but, by deleting your only PLEG device, you may have triggered a re-installation of the code. Try a manual re-installation of PLC:
http://<veraip>:3480/data_request?id=update_plugin&Plugin=3086
And still no joy.
To help, we really need a Status report and a description of what you did, what you expected and what actually happened.

OK… I just decided to start from scratch. Uninstalled PLEG and PLC, then reinstalled. (many reloads inbetween).

Then recreated the routine per Bulldog’s advice. Set the day/time range for something that would work right away. (clicked do it now)

Turned off the Overhead Sink light, so that when the motion is tripped in front hallway, the sink light (as well as two lamps) will turn on.

Went into the hallway and danced jig in front of sensor to trip. No joy. Tried a few times, after reloading, etc… (it is set to arm)

Interested, when I looked at the status report each time, it does NOT seem to be updating with the subsequent tests (if that tells you anything). So the attached report is really from the first test, although I tripped the motion sensor several additional times for the next 10 minutes.

A couple of things:

What on-time is your motion sensor set for? It appears to have been tripped for about twelve minutes. Usually when you are using a separate timer or logic plugin to control the lights, you would set the on-time to minimum.

You may need to change your Condition LightWasOn to include AND LightOn. Right now it will stay true even when the light is off provided ItsMorning occurred after the last time the light was turned on.

[quote=“RexBeckett, post:87, topic:178580”]A couple of things:

What on-time is your motion sensor set for? It appears to have been tripped for about twelve minutes. Usually when you are using a separate timer or logic plugin to control the lights, you would set the on-time to minimum.[/quote]

Sorry… I have no idea what this means. On the trigger tab, for the motion sensor, the only settings I have are:
Event type, set to: A sensor (door/window/motion) is trigger
Drop down: Device is tripped

would the expression look like this:
b and LightOn[/b]

?

Sorry... I have no idea what this means.
When a motion sensor trips, it stays tripped for a certain time before resetting ready for the next trip. This is known as the on-time. It may set with a physical adjustment (knob) or through a configuration parameter on the devices [b]Device Options[/b] tab. I would expect this to be mentioned in the sensor's instruction sheet. We may be able to assist if you tell us the make & model.
would the expression look like this: (LightOn;IsMorning) and LightOn
Possibly. I'm not entirely sure what you wanted the expression to do but it means: [i]The light is on and it last became morning after it was turned on.[/i] Note: it will remain true even when it is no longer morning as long as the light stayed on...

@RexBeckett

Just a status update.
The logic is now working very good. In the scenarios that I have used it in it has worked perfectly.
One thing I am verry happy about is response performance.
I now use one pleg for the bathroom lights, and the response is better than it was with the SmartSwitch plugin.
The on time is in most cases as good as instant. I see the motion detector light turns red and before it goes out the light turns on.

Thank you for your help RexBeckett and RichardTSchaefer!

There’s an updated version of PLEG Basics that includes the new features introduced in PLEG V6.0/6.2. See the first post to download the pdf.

Hi Rex,

Can’t thank you enough for doing this. It’s very helpful and is much appreciated. And of course thanks Richard for creating PLEG in the first place.

Mark

I’ve been experimenting with tweaking your motion-controlled light example from earlier in the thread and some of the thing I was trying didn’t work - possibly they didn’t make sense.

This is so true, and getting it just right is so hard. I haven’t succeeded yet, but I’m getting closer using PLEG than I did with SmartSwitch!

What I am trying is to set a state, let’s say “TVOn” based on someone setting a particular scene from the leviton scene controller (as opposed to casually passing through the room using the regular light switch). Then alter the timer retrigger time based on that variable, extending the motion detector timeout to 2 hours instead of 15 minutes. The thinking was something like:

Condition:
TVTimerDuration = (TVOn ? 02:00:00 : 15:00)

Action:
PLEG StartTimer timerName=xxx intervalTime={(TVTimerDuration)}

well obviously this didn’t work - the condition state is always “null”. I guess my main question is simply whether the condition state can only be an integer value, and not hold strings (or times, if they are effectively a separate variable type)?

Graham

You might also look at my comments on another thread:
http://forum.micasaverde.com/index.php/topic,24312.msg167968.html#msg167968
And the couple of responses after it.

This is what I use for “SmartSwitch” behavior.

You could also add a few more tweaks for your example.

  1. Add a TVONAction … that sets the timer to 2:00:00
  2. Separate the motion and the MotionOn into two conditons.
    This will keep the lights off if someone gets up to go to the bathroom.
    MotionOn will turn on the lights if the lights are NOT currently on and the timer is OFF.
    Motion extends the timer.
    You could even make it a little more sophisticated with low lights (say at 11) when someone moves and the tv is on …

In PLEG Basics, page 21

For action Alarm$Alert action says: Alarm eq “Tripped” and (Alarm$Tripped; !Timer30S)

I believe it should be Alarm eq “Tripped” and !Timer30S and (Alarm$Tripped; !Timer30S) so that the expression will be evaluated when the timer comes to an end. ;D

[quote=“farang, post:95, topic:178580”]In PLEG Basics, page 21

For action Alarm$Alert action says: Alarm eq “Tripped” and (Alarm$Tripped; !Timer30S)

I believe it should be Alarm eq “Tripped” and !Timer30S and (Alarm$Tripped; !Timer30S) so that the expression will be evaluated when the timer comes to an end. ;D[/quote]

Strictly speaking, your version of the expression is more correct. However, if the !Timer30S timestamp is later than that of Alarm$Tripped the timer must have ended…

[quote=“RexBeckett, post:96, topic:178580”][quote=“farang, post:95, topic:178580”]In PLEG Basics, page 21

For action Alarm$Alert action says: Alarm eq “Tripped” and (Alarm$Tripped; !Timer30S)

I believe it should be Alarm eq “Tripped” and !Timer30S and (Alarm$Tripped; !Timer30S) so that the expression will be evaluated when the timer comes to an end. ;D[/quote]

Strictly speaking, your version of the expression is more correct. However, if the !Timer30S timestamp is later than that of Alarm$Tripped the timer must have ended…[/quote]

However, it didn’t work when I set it up according to the example. Nothing happened after the timer ran out of time (The expression did not evaluate as true when I looked at the status page). It works now though after my modification. I am a newbie so I can’t tell why. :smiley:

Probably because the Alarm was not tripped when the timer expired.

No that’s not the case. I start a new thread in case you guys like to have a look into it. Thanks. ส็็็็็็็็็็็็็็็็็็็(ಠ益ಠส็็็็็็็็็็็็็็็็็็็

Here is my simple goal. Use the ping sensors to trip a virtual switch to indicate when either someone is home or not. Seems simple enough :slight_smile:

I created my ping sensors, they behave as expected.
I created a virtual switch
I’ve attached my status.
I’m pretty sure I had a one phone thing working and tried to add a second which would never work. I went back to one phone and now it’s not working correctly :frowning:
Note, I use the inverted option. I’ve been testing by switching between inverted and normal.

Thoughts?