PLEG is scrambling my brain!

I have a Vera3 (1.5.622 ) and Program Logic Core, Program Logic Event Generator and Program Logic Event Timer Switch (all V6.8). I have spent 3 days trying to get a simple scene to work under PLEG. I have a motion detector and a single switch that controls a single light. What I want to happen (to start really simply) is have the light come on when the motion dectector detects motion, the light to stay on for 5 minutes, then switch off again.

I have tried numerous examples from the forum and Richard’s Beginner’s Guide but I have had no success. The problem is that the simple examples always add some complication that I do not need and/or the instructions skip (to me!) crutial steps and/or do not mention buttons/pull downs that I see. The best I have managed is to switch the light on when motion is detected but it never goes off!

If I can get this simple example working the only addition I want to make is to have the light only come on if it is between 1 hour before sunset and 1 hour after sunrise (i.e. when it is likely to be dark). Is this feasable with PLEG?

I’m pulling my hair out over this - I’m not thick but I cannot grasp some of the concepts of PLEG as much as I try. I used to debug kernel-mode devices drivers a few years ago - that seemed a breeze to me :frowning:

Sorry for rambling on.

JohnK.

You need two conditions … one to turn the light on … it sounds like you have managed that … And one to turn the light out.

Please post your current status report (PDF preferred) and we can point you in the right direction, using your input names.

Richard,

See the attachment. I am using a 13A socket temporarily and have set the on-time to 16 seconds - just for testing.

Thanks for the response.

JohnK.

Looks like you got the light on, no problem
LightOn = Motion

Now I’m not one to use the timer, but the timer should be more accurate then what I’m going to show you so… You can try out my way for now and learn that, but we both can learn something more once someone else post how to use the timer. Here it goes…

LightOff = LightOn; Now > 05:00

Which just means ruffly 5 minutes after LightOn was true, turn off the light. This won’t add a 5 min. timer if you manually turn on the light. For that you would need to change “LightOn” to the actual light switch.

I use the Day and night app and I have my offset to 00:20 or 20 minutes. You can set your offset to what ever you want in the day and night app.

To add this to the above we wouldn’t need to change the “off” condition just the on. And it would look like this.

LightOn = Motion and Night

You can also add a door sensor to this to make it more reliable.

Success! It now works thanks. Detects movement and switched the light on, then a delay of about 5 minutes then light goes off :slight_smile:

@integlikewhoa: You write:

I use the Day and night app and I have my offset to 00:20 or 20 minutes. You can set your offset to what ever you want in the day and night app.

To add this to the above we wouldn’t need to change the “off” condition just the on. And it would look like this.
LightOn = Motion and Night

Can you explain this more fully? I’ve download the DayNight plugin but am completely lost as what to do next :-\

-JohnK.

PS: I’ve attached the PLEG Report.

Sorry I was not available yesterday …

Setup the Day or Night Plugin. I use the following settings:
-00:15:00 relative to sunrise
+00:15:00 relative to sunset
You also need to make sure your Location and Time zone are setup properly in the Vera Setup → Location tab.

To use Day or Night. Add a new Input Trigger … Call it Night … and bind it to the Day or Night Plugin that indicates Night.

Modify your AutoOn condition to be:
Motion and Night

integlikewhoa and RichardTSchaefer,

Thanks for the help - it is now working perfectly and I am starting to understand PLEG a little more.

I have a couple more questions:

  1. Why is the time delay so inaccurate?
  2. How do I use the timer plugin instead?

…and for integlikewhoa:
can you explain this a bit more…

This won't add a 5 min. timer if you manually turn on the light. For that you would need to change "LightOn" to the actual light switch.

Regards,

JohnK.

Why is the time delay so inaccurate?

Which time delay are you referring to …
The use of the NOW keyword is a built-in 1-Minute interval timer. So it causes things to be evaluated once a minute.

You can create precise timers in the Input Schedule section … With 1 sec accuracy. Then use them in the sequence expressions.

You may want to review:
http://forum.micasaverde.com/index.php/topic,21603.0.html

As Richard said “NOW” just mean to recheck every min. So it could be on time or could be up to a min. off.
Now for shutting lights back off I have never had a complaint about timer ranging up to a min. So usually never a problem, but yea if you sit there with a stop watch you’ll notice it not exactly 5 min.
Now if your trying to shut something off 10 sec. after it’s turned on then “Now” probley going to be a big problem. Since it could be anything from 10 secs to a min. and 10 secs.

[quote=“kennedyj, post:7, topic:181180”]…and for integlikewhoa:
can you explain this a bit more…

This won't add a 5 min. timer if you manually turn on the light. For that you would need to change "LightOn" to the actual light switch.
[/quote]

The off command “LightOff = LightOn; Now > 05:00” Says that the light turns off 5 min’s after the light LightOn code came true. That’s how it brakes down. LightOn > 5:00 basically

What that means is that if you reached in and turned on the lights, without triggering you the “LightOn” automation (which is Night and motion). The light would never turn off.

What this also means is that 5 min after the last time “LightOn” was true the light will shut off. So if you camping on the toilet and not flapping your arms to set off the motion over and over again, the light will shut off on you 5 min. after the last time it was tripped.

I like to throw in more variables. The more the merrier. Add a door sensor to this. Light only turns off or timer only starts after the door has been reopened (showing you left the restroom, or finished). This only works if you use the restroom with the door closed.

You can set an input as the light switch (call it ToiletLight for my example) and set an off command like this

LightOff = ToiletLight and (ToiletLight; Now > 05:00)

That would turn off the light 5 min after that light turned on no matter why it turned on as long as the following is true
The light is still on and its been 5 min. since it was turned on.

So if you camping on the toilet and not flapping your arms to set off the motion over and over
LOL!

The behavioral side effects of Automation.

I recently had Guests over … and the lights go on for 2 min by Motion sensor when you enter the room. They wanted to go to bed … so they told me it took them a while but they were finally faster than the motion detector in running back to the bed, after manually turning the lights out, before the lights went back on.

Sorry integlikewhoa, I’ve been away on business for a few days…

I thought I was starting to understand PLEG but I’m still floundering.

I’m now trying to ensure the light goes off after a delay when the pull switch is operated during the day. You said:

You can set an input as the light switch (call it ToiletLight for my example) and set an off command like this

LightOff = ToiletLight and (ToiletLight; Now > 05:00)

That would turn off the light 5 min after that light turned on no matter why it turned on as long as the following is true
The light is still on and its been 5 min. since it was turned on.

I’m having trouble with understanding this :frowning: Can you look at the attached report and tell me what I have to do?

Thanks, JohnK.

[quote=“kennedyj, post:11, topic:181180”]Sorry integlikewhoa, I’ve been away on business for a few days…

I thought I was starting to understand PLEG but I’m still floundering.

I’m now trying to ensure the light goes off after a delay when the pull switch is operated during the day. You said:

You can set an input as the light switch (call it ToiletLight for my example) and set an off command like this

LightOff = ToiletLight and (ToiletLight; Now > 05:00)

That would turn off the light 5 min after that light turned on no matter why it turned on as long as the following is true
The light is still on and its been 5 min. since it was turned on.

I’m having trouble with understanding this :frowning: Can you look at the attached report and tell me what I have to do?

Thanks, JohnK.[/quote]

First you need to add an input/trigger for the “toiletswitch” so PLEG knows if the light is actually on or off.
Right now if you turned on the light switch manually PLEG has no way of knowing its on.

After that you need to change you condition to turn the light off after the light is turned on rather then after the “AutoOn” is activated.

See right now you say if PLEG AutoOn then turn off 2 min after that. But this doesn’t do anything if PLEG didn’t turn on the light and you manually did it.

Your adjusted/changed condition would be

AutoOff = ToiletLight and (ToiletLight; Now > 02:00)

Make sense? If ToiletLight still on 2 min. after Toilet light came on (no matter how it came on) it will go off.

Before it was:
AutoOff = AutoOn; Now > 02:00

This doesn’t take into account if the actual current status of the light (is it on still or not).

Actually I would make a few more modifications:

Set the “Repeat” to yes for AutoOn. May not be needed if the Motion sensor stays on longer than the 2:00 minutes.

[quote=“RichardTSchaefer, post:13, topic:181180”]Actually I would make a few more modifications:

Set the “Repeat” to yes for AutoOn. May not be needed if the Motion sensor stays on longer than the 2:00 minutes.[/quote]

I feel shorted! You said a few and I only see one. What else you got in mind?

Richard can you aslo help explain what the Repeat would do in this case?

Depends on the speed of the motion sensor … In my house I have very fast motion sensors (wired to DSC alarm).

The repeat would allow the the motion to be extended to 2:00 past the last motion, not the first motion.

Many of the battery powered Z-Wave motion sensors will trigger a motion, and then indicate motion for 5 minutes … even if there is no motion.
Also if there is continuous motion … it will not send an update to Vera until all motion has stopped for what ever period is defined for the sensor.

For Battery powered Z-Wave devices I do not recommend turning lights off based on a fixed time from when motion starts … I recommend that you turn off lights when the motion sensor indicates NO motion. And if the default time of 5 minutes is to long … than change the motion sensor timeout. (i.e. the timeout is in the motion sensor and not the AUTOOFF condition in PLEG.

GE panel here wired motions. Mine kick on for few seconds then kick off.

I guess I’m still confused on this. I always thought PLEG looked at that last time it was “true” (motion tripped) and if my motion tripped again during that time the last true on the motion would be changed, there for it would extend.

[quote=“RichardTSchaefer, post:15, topic:181180”]Many of the battery powered Z-Wave motion sensors will trigger a motion, and then indicate motion for 5 minutes … even if there is no motion.
Also if there is continuous motion … it will not send an update to Vera until all motion has stopped for what ever period is defined for the sensor.[/quote]
Thanks unaware as never used battery devices yet.

integlikewhoa,

I’m still having trouble here - I just cannot get my head around it.

You can set an input as the light switch (call it ToiletLight for my example) and set an off command like this

LightOff = ToiletLight and (ToiletLight; Now > 05:00)

That would turn off the light 5 min after that light turned on no matter why it turned on as long as the following is true
The light is still on and its been 5 min. since it was turned on.

What is the variable “ToiletLight” ? How do I set it as an input? What is the input?

Sorry for being a pain.

JohnK.

ToiletLight is the pyhsical zwave switch or the light your turning on and off. You have it named as something but I don’t know where it is. There is no variable.

It’s the switch (what ever you have it named) is turned on.