PLEG Help Please!!

I am at the last straw with this as I cannot seem to get it to work. Basically here is what I am trying to accomplish. My Wife and I both have a virtual switch that is repsententative of our iPhone and OFF = We have exited the geofence of home (via iViri App) and ON = We have entered the geofence of home (via iViri App). Using PLEG I want it to do 4 things.

1.) If it is Night time and either one of us return home have it fire a scene to turn on 5 specific lights (this works)
2.) If both devices have left the house I want the house to lock up and run a scene to shutdown all lights, etc… (this works)
3.) If condition 2 is true and a timed interval (for testing 4 minutes) has passed I want it to activate our Vacation Virtual Switch which activates Ghost and changes the behavior of the thermostat… (this works) However, I want it to cancel if condition 2 is no longer true before it hits the timed interval, which is where I am having issues. It doesn’t ever cancel, its like PLEG once the first condition is evaluated to be true it ignores it and just moves onto the second condition, the timed event and nothing can cancel it.
4.) If either iPhone comes home at any time of the day or night it will turn off vacation.

Below is my status from the PLEG, please help!!!

Triggers

Name Description State Last True Last False
t1 Jarod’s iPhone is turned on true 2014-03-12 15:06:25.909 2014-03-12 14:53:46.694
t2 Lauren’s iPhone is turned on false 2014-03-12 15:04:16.571 2014-03-12 15:04:34.652
t3 Day or Night indicates Night time. false 2014-03-12 14:53:33.009 2014-03-12 14:53:36.978
Conditions

Name Repeat Expression State Last True Last False
c1 No t3 and ((t3;t1) or (t3;t2)) false 2014-03-12 14:51:53.982 2014-03-12 14:53:30.163
c2 No ((not t1) and (not t2)) false 2014-03-12 15:04:34.657 2014-03-12 15:06:25.915
c3 No (c2; now > 4:00) true 2014-03-12 15:08:42.107 2014-03-12 15:04:34.678
c4 No t1 or t2 true 2014-03-12 15:06:25.917 2014-03-12 15:04:34.679

c3 = (c2; now > 4:00)

should be:

c3 = c2 AND (c2;NOW>4:00)

[quote=“Bulldoglowell, post:2, topic:180148”]c3 = (c2; now > 4:00)

should be:

c3 = c2 AND (c2;NOW>4:00)[/quote]

testing…

[quote=“Bulldoglowell, post:2, topic:180148”]c3 = (c2; now > 4:00)

should be:

c3 = c2 AND (c2;NOW>4:00)[/quote]

It worked!!! Awesome, I just couldn’t figure it out and this completely makes sense.

The often misunderstood sequence operator!

The following expression:

(c2;NOW>4:00)

Will turn true roughly 4 minutes after c2 last became true. Independent of the current value of c2!
It is false immediately after c2 became true and will stay that way for roughly 4 minutes. Independent of the current value of c2!

Why ? Because a sequence expression only cares about the time stamp of the input or condition and not the current value of the condition. The changing of the state only indirectly effects the value of a sequence expression. It’s indirect because changing the state may change the on or off time stamp that the sequence expression is based on.

PLEG is the first plugin to attempt to integrate timing logic into normal boolean logic.
Even seasoned programmers can have a problem with it until they review and understand it’s behavior.

[quote=“RichardTSchaefer, post:5, topic:180148”]The often misunderstood sequence operator!

The following expression:

(c2;NOW>4:00)

Will turn true roughly 4 minutes after c2 last became true. Independent of the current value of c2!
It is false immediately after c2 became true and will stay that way for roughly 4 minutes. Independent of the current value of c2!

Why ? Because a sequence expression only cares about the time stamp of the input or condition and not the current value of the condition. The changing of the state only indirectly effects the value of a sequence expression. It’s indirect because changing the state may change the on or off time stamp that the sequence expression is based on.

PLEG is the first plugin to attempt to integrate timing logic into normal boolean logic.
Even seasoned programmers can have a problem with it until they review and understand it’s behavior.[/quote]

Thanks for the explanation. At the time I think if you would have sent me this I would have just wanted the answer since I had been beating my head against the wall for a couple of days trying to figure it out but now that it works and reading this it makes a lot of sense and I can appreciate what you are trying to do with PLEG. Also this is proving to be very well incorporated with the iViri Geofencing options and having your house react to the condition of you leaving or entering different geofences. Already making stuff happen based on where my wife and I are. Exciting stuff.