PLEG - Schedule Won't Turn Fan Off

My first PLEG. I’m basically just copying the example of the simple motion triggered light from the guide:

Example ? Simple Motion-Triggered Light Turn on a light when a motion-detector is tripped at night. Turn it off if there has been no motion for 10 minutes. Ignore motion for 30 seconds after light is turned off. The light may be locked on by rapid on/off/on of the light switch (requires a light switch with instant or very rapid status reporting). The motion sensor should be configured with a short on-time (less than the interval time). None of the Conditions require Repeats to be checked. Triggers LightOn Motion ItsNight Light is turned on Motion Sensor is tripped DayTime indicates night Schedules Timer On: Self-ReTrigger Off: Interval 10:00 Conditions AutoOn KeepOn AutoOff !LightOn and ItsNight and Motion and (!LightOn; Motion > 30) (LightOn and Motion and (LightOn; Motion)) or AutoOn LightOn and !Timer and (LightOn; !Timer) and (!LightOn; LightOn > 10) Actions AutoOn KeepOn AutoOff Turn Light on PLEG StartTimer timerName=Timer Turn Light off

In my case it’s a fan. I’m going to want to control it with a combination of motion and temperature but right now I’m just trying to get it to work with motion only. It turns on OK but won’t turn off. Can’t understand why it won’t work as it looks (to me) just like the example. Attached my status report.

First problem,
Since you reference cAtticFanOn in cKeepAtticFanOn
cAtticFanOn needs to be in the condition list before cKeepAtticFanOn as conditions are evaluated in order.
Don’t know if that is the only problem but it was the most obvious (since I just had a problem with that myself).

I believe the condition list is the only one that is order sensitive like that.

So in the guide it shows this for keeping the light on:

(LightOn and Motion and (LightOn; Motion)) or AutoOn

AutoOn being their condition for turning the light on. So you’re saying that the guide is wrong and that my condition should change from:

(tAtticFanOn and tAtticMotion and (tAtticFanOn; tAtticMotion)) or cAtticFanOn

to:

cAtticFanOn or (tAtticFanOn and tAtticMotion and (tAtticFanOn; tAtticMotion))

Is that right?

No, I mean the order of the row in th Condition Table itself.

It looks like if you go to the Conditions tab you have
cKeepAtticFanOn is the name of the condition int the first row.
cATticFanOff in the second row
cAtticFanOn in the third row.

The Condition cAtticFanOn needs to be the first condition in the table, in the first row. Because it needs to be evaluated befor cKeepAtticFanOn.

You didn’t follow the sample exactly because you put cAtticFanOn in a row after cKeepAtticFanOn.

Hope that helps and makes sense, the ordering of the rows in the Condition table matters. Not the order of statements inside each row.

Ahhh! (smacks forehead). The +/- buttons!

Makes perfect sense. Was thinking of each one as a totally separate entity. Thx!

So I switched those around and the fan is still staying on. There are a couple of things I don’t understand. In the example from the guide it says it ignores motion for 30 seconds after the light is turned off. The code looks like this:

!LightOn and ItsNight and Motion and (!LightOn; Motion > 30)

It also says it will turn off if there has been no motion for 10 minutes and that code looks like this:

LightOn and !Timer and (LightOn; !Timer) and (!LightOn; LightOn > 10)

Wouldn’t these both indicate seconds instead of minutes? If it were 10 minutes it seems that it should look like this > 10:00. Maybe that’s wrong but it sure doesn’t seem like the 10 & 30 should be written the same when one is seconds and the other is minutes.

The timer is the 10 minutes,the expression !LightOn; LightOn > 10 means the on off light then on light status occured in a time frame that was greater than 10 seconds (aka if it happened in less then 10 seconds you were trying to over ride the timer).

attach a new status report now that you have things in the right order, with the fan tripped on (and hopefully the timer in a true state).

Getting somewhere. I realized that I set the keepfanon action to the fan instead of the pleg timer. I fixed that and now it turns off like it should after 10 minutes.

Then I realized that the 10 in the code wouldn’t be the reference to 10 minutes because that was in the timer but I was at a loss so thanks for that. Makes sense.

The problem that remains is that it’s not staying on now, when there is continuous motion going on. This is something with the motion sensor reset timing though and looks like it’s discussed thoroughly here: http://forum.micasaverde.com/index.php/topic,14709.0.html

I’ll go over there & check it out.

Thanks much for the help shallowearth.

First thing I would do is remove this statement from your trigger: (!LightOn; Motion > 30)
You likely don’t want that behavior in the situation you are in.
Make sure you set your motion sensor time out to something very short. What kind of motion sensor are you using?

Based on what I read I’m re-thinking the whole thing. I have a Ecolink PIR. It’s battery operated. If there is additional movement within 5 min. it stays tripped. So I think? - all I need is this:

[code]tAtticFanOn Attic fan is turned on

tAtticMotion Attic motion sensor is tripped

tAtticNoMotion Attic motion sensor is untripped

cAtticFanOn !tAtticFanOn and tAtticMotion

cAtticFanOff tAtticFanOn and tAtticNoMotion[/code]

Enter the attic, the fan turns on. More motion within 5 minute intervals means the motion sensor stays tripped. No motion for 5 minutes, the motion sensor untrips and the fan turns off. If I find that 5 min. is too short I can change the tripped-state timer of the motion sensor.

I wouldn’t even use PLEG except I am going to add a temperature variable. Once I’m done testing I’m only going to want this to happen when it’s 77 deg. or higher, and then the fan to turn off if the temp goes below 77. So then I think I need to change this:

cAtticFanOn		!tAtticFanOn and tAtticMotion

to this:

cAtticFanOn		!tAtticFanOn and tAtticAbove76 and tAtticMotion

and this:

cAtticFanOff		tAtticFanOn and tAtticNoMotion

to this:

cAtticFanOff		(tAtticFanOn and tAtticNoMotion) or (tAtticFanOn and tAtticBelow77)

Am I writing that last one properly?

Yes, that all looks correct.

You can also use the following and save two inputs:

cAtticFanOff tAtticFanOn and (!(tAtticMotion or tAtticAbove76))

The last part basically says requires that there is that there is no motion AND that the temperature is not hot:
((NOT tAtticMotion) AND (NOT tAtticAbove76))
Using Demorgan’s law (logic transformation) … this is equivaluent to
(NOT (tAtticMotion OR tAtticAbove76))
And in PLEG you can use ! to represent NOT.

Thanks again shallowearth.

Richard, I knew from the guide that you could just reverse the conditions using ! for not. I wasn’t sure it would work when the temp went down. Thanks for the simplification.