Sequence Events

Gents, I’m having a problem with a sequence, I’m hoping someone can spot what is wrong here.

Scenario:
Sensor’s: 4in1 Motion mounted above a door and a Binary Door sensor on the same door.

Aim: To have the PLEG compute Entry and Exit to the house.

Triggers:
FrontDoorOpen Front Door Sensor armed is tripped 2013-07-23 09:10:57.788 false
FrontDoorClosed Front Door Sensor armed is not tripped 2013-07-23 09:11:03.102 true

MotionTrip Front Motion Sensor armed is tripped 2013-07-23 09:32:28.461 false

Conditions:

Exit MotionTrip;FrontDoorOpen 2013-07-23 09:10:57.791 false
Entry FrontDoorOpen;MotionTrip 2013-07-23 09:50:42.955 true

For some explicable reason, since upgrading to V4.5 Entry now trips without FrontDoorOpen (the door isn’t opened) whilst Exit appears to function as expected!

Those time stamps are invaluable in trouble shooting, thanks RTS.

Anyone with any bright ideas on why the sequence works one way and not the other or do I have a phantom trigger?

Sequence expressions are only concerned with the time stamp of the elements.

So:
Entry FrontDoorOpen;MotionTrip

Will fire the first time you get a MotionTrip after the FrontDoorOpen events happen.
Even if it was yesterday and the door has been closed.

Arrrrghhh, not what I wanted to hear…

Can they be coded so that they have to occur within, say 5 secs of each other?

Yes, see the 2nd half of:
http://forum.micasaverde.com/index.php/topic,15638.msg119147.html#msg119147

Thanks, so if I’ve read this right:

Exit MotionTrip;Now;FrontdoorOpen
Entry FrontDoorOpen;Now;MotionTrip

Should work sequentially…

Thanks, so if I've read this right: [b]Entry[/b] FrontDoorOpen;Now;MotionTrip
No! [b]NOW[/b] only makes sense as a middle term in a sequence expression when the last term is a [b]Literal Time[/b], i.e. 22:00:00. Before MotionTrip happens, it will have the previous timestamp. So this is false. When it happens it will have the same time as [b]NOW[/b] So this is false. The only way to have a time in the future that is after [b]NOW[/b] is with a literal time stamp.

[hr]
I pointed you to some documentation … but I will answer your previous question explicititly.

Can they be coded so that they have to occur within, say 5 secs of each other?
Yes, there are two forms of the sequence expressions. Ordered, and UnOrdered.

[ul][li]Ordered:
Entry FrontDoorOpen; MotionTrip < 5
True if MotionTrip is set to true within 5 seconds After FrontDoorOpen is set to true. [/li]
[li]UnOrdered:
Entry FrontDoorOpen, MotionTrip < 5
True if both evenets are set to true within 5 seconds of each other, either can be first.[/li][/ul]

Many thanks.

I was looking at it from the view that the sequence had to be followed in order, for example each condition had to follow after each other’s timestamp in ascending order to be true.

Not over yet, I would have expected the reverse to be Exit.
ie Exit MotionTrip <5; FrontDoorOpen, but it returns the following error.

Program Logic : MotionTrip <5; FrontDoorOpen: Illegal Count Expression: MotionTrip <5; FrontDoorOpen

If I put it in brackets, I get:

Program Logic : (MotionTrip <5); FrontDoorOpen: attempt to compare two nil values

Reread the references I sent.

The general form for ordered sequence is (Semi Colon Separated):
V1; V2; V3; … ;VN < HH1::MM1::SS1 > HH2:MM2:SS2

These are ordered … V1 thru VN must be in the specified order and the difference from Time of V1 from Time of VN must be less than interval 1 and greater than interval 2. The interval specifications are optional.

The general form for unordered sequence is (Comma Separated):
V1, V2, V3, … ,VN < HH1::MM1::SS1 > HH2:MM2:SS2
The difference from the oldest sequence time to the newest sequence time must be less than interval 1 and greater than interval 2. The interval specifications are optional, but really do not make sense without at least one of them.

MotionTrip;FrontDoorOpen < 5
?

This is true if the front door is opened within 5 seconds after the motion is tripped.

Thanks both of you, RTS, I hope I haven’t made you bald with all the hair pulling you must have been doing to get me through this.
:slight_smile:

I’ve just thought this through a bit further and now am puzzled why I’ve been using:

LowLight LightLevel1 < 40

I did this so I could easily change the trigger point of luminosity, rather than specifying it in the Trigger.
Doesn’t this imply LowLight is true if LightLevel1 is tripped within 40 secs therefore totally inappropriate for this conditional statement.

Obviously, this must be the wrong expression to use for comparing Variables, is there a method of doing this in PLEG or should I just leave it within the Trigger Action?

No because a sequence expression has at least two items separated by a comma or semi-colon.

Richard, I’ll eventually get a handle on this…Thanks. :slight_smile:

well, it did work a couple of times…

Now for some reason the Conditional Statements won’t do what is expected from the triggers…

FrontDoorOpen Front Door Sensor armed is tripped 2013-07-24 16:20:08.936 false
FrontDoorClosed Front Door Sensor armed is not tripped 2013-07-24 16:20:13.496 true
MotionTrip Front Motion Sensor armed is tripped 2013-07-24 16:20:02.356 true

Entry FrontDoorOpen; MotionTrip < 5 2013-07-24 12:30:59.701 false
Exit MotionTrip; FrontDoorOpen < 5 2013-07-24 14:46:50.909 false

Looks right to me … It took 6+ seconds from motion to when the door was opened.
You required that it be done in less than 5 seconds for the Entrycondition to be true.

you have the option to run or change it to more seconds :smiley:

^^^
Increasing the time to 7 solved the problem, oddly I initially used
Exit MotionTrip; FrontDoorOpen < 7 which returned a null.

Dropping the < 7 so the condition is:

Exit MotionTrip; FrontDoorOpen

Works a treat. :slight_smile: Although the sequence could trigger on Entry if Motion Trip has been triggered from inside.

Thanks guy’s for the assistance.

I’ve been playing with PLEG for a few weeks, and very, very slowly, working logic into the fold. I’ve been able to screw up even very straightforward condition statements, so I’m being cautious.

I have a similar implementation to the OP’s, but at this time I’m only concerning myself with Entry. I would like to turn on lights if:

[ul][li]it’s nighttime,[/li]
[li]the door is opened,[/li]
[li]and motion has not been detected (not tripped) inside for at least 2 minutes.[/li][/ul]

applicable inputs:
Dusk_t1 - Day or Night indicates Night time
Main_Entry_Door_Opened_t4 - Front or Garage Entry Doors tripped
1st_Floor_Motion_Not_Tripped_t5 - 1st Floor Motion Sensor is not tripped

applicable conditions:
Main_Door_Entry_c4 - 1st_Floor_Motion_Not_Tripped_t5; Main_Entry_Door_Opened_t4; NOW > 2:00
Main_Door_Entry_At_Night_c5 - Dusk_t1 AND Main_Door_Entry_c4

action:
turn on some lights

I’ve taken to appending a “t#,” “s#,” or “c#” at the end of my stuff to easily differentiate triggers, schedules, and conditions, but that’s uncovered a bug in the auto-update of condition expressions when changing trigger names or even adding new ones. I’ll try to capture that in another thread. I haven’t yet tested the expression above, but it’s my first attempt at sequences & I’ll try it live tonight.

EDIT: everything I try results in an illegal count expression… still working on it.

Try decomposing your first condition as follows:

Main_Door_Entry_120_c4: 1st_Floor_Motion_Not_Tripped_t5; NOW > 120
Main_Door_Entry_c4: Main_Door_Entry_120_c4; Main_Entry_Door_Opened_t4