need help with sequence

Hi, i want to program pleg to run a sequence.

I have a ping sensor on both mine and my wifes phone (PING1, PING2).
Each ping sensor switches a virtual switch in the mulit switch plugin.(SWITCH1, SWITCH2)
And i also have a door sensor on front door.(DOOR)

So i would like to program something like this
if SWITCH1/SWITCH2 is active before DOOR = ex. turn lights on in the hallway

So how can i use PLEG to make sure the ping sensor is triggered before the door opens, and then run an action?

Try something like this:

Conditions
AnyPing SWITCH1 or SWITCH2
PingB4Door (AnyPing; DOOR)

If you want AnyPing to fire when a new Ping occurs even if there is already one true, set Repeats on.

You may need to add additional terms if you want to limit when PingB4Door fires.

What do I add to make fire only with in 5 minutes?

What do I add to make fire only with in 5 minutes?

Do you mean that you only want it to fire if the door is opened within five minutes of AnyPing becoming true?

If so, try:

PingB4Door (AnyPing; DOOR < 5:00)

That’s exactly what I mean.
Btw, why do I need two conditions?
Can’t I just write it in a single one like:
SWITCH1 or SWITCH2; and DOOR

Or will it be very wrong??

Now it’s a bit slow when opening the door. It takes just to long time to turn on light. So it’s faster to turn on light manually. Like 1-2 seconds. Could it be made faster?

Can't I just write it in a single one like: SWITCH1 or SWITCH2; and DOOR

No. That is not a valid expression. See PLEG Basics for how Logical expressions and Sequence expressions work.

Now it's a bit slow when opening the door. It takes just to long time to turn on light. So it's faster to turn on light manually. Like 1-2 seconds. Could it be made faster?

The PLEG logic is not perceptively slowing it down. Most likely the delay is due to Z-Wave transmission time. PLEG’s Status report will show you the timing of the Inputs and Conditions.

The transmission delay will be worse if the devices are some distance from Vera and/or your Z-Wave mesh is sparse. You could improve response time by directly associating the light with the door switch but then you would not be able to have the ping conditions.

[quote=“RexBeckett, post:4, topic:185371”]

What do I add to make fire only with in 5 minutes?

Do you mean that you only want it to fire if the door is opened within five minutes of AnyPing becoming true?

If so, try:

PingB4Door (AnyPing; DOOR < 5:00)[/quote]

Rex,
I have a sequence where I want it only to trigger when LESS THAN 30 seconds since a variable was last False. It is not working as expect; It fires on any change even if that change occurred hours or days ago…

(
(!GuestMode and (GuestMode; !GuestMode < 30))
or
(!GuestSecureMode and (GuestSecureMode; !GuestSecureMode < 30))
)
AND
(DisarmMode or SleepMode or VacationMode or StayMode or AwayMode)

… the items after the AND change frequently but I only want the Condition to be True for when GuestMode or GuestSecureMode changes from True to False.

Where is my logic wrong?

[quote=“Aaron, post:7, topic:185371”]I have a sequence where I want it only to trigger when LESS THAN 30 seconds since a variable was last False. It is not working as expect; It fires on any change even if that change occurred hours or days ago…

(
(!GuestMode and (GuestMode; !GuestMode < 30))
or
(!GuestSecureMode and (GuestSecureMode; !GuestSecureMode < 30))
)
AND
(DisarmMode or SleepMode or VacationMode or StayMode or AwayMode)

… the items after the AND change frequently but I only want the Condition to be True for when GuestMode or GuestSecureMode changes from True to False.

Where is my logic wrong?[/quote]

I had this same issue and the problem is in the sequence expression. What you want is to return true if the GuestMode or GuestSecureMode was false less than 30 seconds ago. The sequence expression in the example is checking to see if the timestamp for GuestMode and !Guestmode, or GuestSecureMode and !GuestSecureMode occurred less than 30 seconds apart which will ALWAYS be true because those timestamps will be literally milliseconds apart, if not the exact same time. and not if they happened 30 seconds from present time. The time relationship between the 2 events will be the same until the next status change occurs.

My example used 2 minutes instead of 30 seconds, so I used NOW in my sequence, which won’t work in this example because NOW only fires once a minute. You would be able to do the same if you were willing to give up a bit of ‘resolution’ in your condition.

( (!GuestMode and (!GuestMode; now < 2:00)) or (!GuestSecureMode and (!GuestSecureMode; now < 2:00)) ) AND (DisarmMode or SleepMode or VacationMode or StayMode or AwayMode)

If you wanted to keep the 30 second resolution, I’m sure a timer could be created in PLTS (I haven’t used this yet) or you could create a virtual switch ModeSwitch that toggles when either GuestMode or GuestSecureMode become false and then toggles back after 30 seconds using a delay and add it to the condition.

(!GuestMode or !GuestSecureMode)
AND
(DisarmMode or SleepMode or VacationMode or StayMode or AwayMode)
AND
ModeSwitch

@Aaron

I edited my original post as I had an error in my explanation, but the examples didn’t change.

V

Since GuestMode is binary i.e. it changes from true to false to true …

The following:

(!GuestMode and (GuestMode; !GuestMode < 30))

Is ALWAYS equivalent to:
!GuestMode

Same with the GestSecureMode part of the expression.

Clearly you are trying to do something with timing … but I do not understand your logic.

Maybe you want (I am just guessing):

GuestModeOff !GuestSecureMode or ! GuestMode
MiscMode DisarmMode or SleepMode or VacationMode or StayMode or AwayMode
DoSomething MiscMode and (MiscMode; GuestModeOff)

You may want repeats turned on for GuestModeOff.

@Aaron

Your example piqued my curiosity about self-triggered timers in PLEG. After doing some research, I think this is the best way to achieve what you are trying to do, without involving other plug ins and muddying the waters.

You would need to create a schedule ModeTimer with a start type of Self Trigger. Choose Interval as your Stop Type and 30 for your time.

You would then need to create additional conditions that would make this work.

The first condition could be called ModeTimerStart and would be as follows:

(!GuestMode or !GuestSecureMode) AND (DisarmMode or SleepMode or VacationMode or StayMode or AwayMode)

and the action attached to this would be to start the timer. It took some searching to find out how to do this, but click the Actions tab and select Edit on this condition. Then select the Advanced tab and select the PLEG device you are using from your ‘Pick a Device’ drop down. Click ‘Add’.

Select ‘Start Timer’ from the dropdown and enter ModeTimer in the timerName box. Nothing needs to be put in the intervalTime box

Create a condition called ModeTimerActive which is satisfied when ModeTimer is active. Attach the actions to this condition as it will only be true from the time ModeTimerStart was satisfied to 30 seconds afterward.

@Richard & Vodden
I’m trying have PLEG catch the change from GuestMode to NOT GuestMode - thus, want the Condition to be True ONLY when that occurs. The other section: (DisarmMode or SleepMode or VacationMode or StayMode or AwayMode) must also be true separately. So my issue is only with getting the condition to be true ONLY at the time Guest or GuestSecure modes change - at that time, and then the Condition should no longer be True after that moment.

I have not found a way to do a simple ‘on change’ for a Device.

Richard… is there a simple way to tell PLEG when ‘DEVICE’ changes from True to False?

@Aaron

My last example would work and the timer duration could be shortened to only 1 second. The timer would start the instant that !GuestMode or !GuestSecureMode was tripped (along with the other condtions specified), and then would end 1 second later. Therefore, the condition ‘ModeTimerActive’ would only be true for 1 second.

That’s what I though … so what I have will work.

You can’t do what you want in a single condition.

If you want X to be true when !Y happens after Z you would use a sequence expression:

X Z and (Z; !Y)
Z needs a timestamp … so it can’t be an expression … it must be a condition or an input.
[hr]
When you have complex expressions it’s best to simply them into pieces … that combine what you can once things are working.