PLEG for leaving the house

I’ve been reading for a couple weeks and when I think I start to understand it turns out I’m just more confused. I’ve finally given up and I’m hoping someone can just help me.

I have the ping plugin installed. My original hope was to just base a scene off of that. If my phone wasn’t on the network, vera could lock the door and turn the garage light. However, my phone for whatever reason pops off the network at random times so that alone isn’t enough.

So I read about PLEG and thought if I could combine my phone being off the network, with the garage door sensor saying that the one of the garage doors has opened (not necessarily in that order) that it would be a good indication that I have actually left and the phone isn’t just dropping the wifi connection.
I also wanted to have it so it worked when my wife left instead of me.
I think I’ve setup the proper triggers.
“sarah” if sarah’s phone is tripped (tripped meaning the Ping plugin can’t reach it). “tim” if tim’s is tripped.
“crv” if the crv’s garage door is opened and serenity if serenity’s garage door is opened.

I just can’t figure out the proper logic for the condition.
I want it to lock the door and turn off the light if crv or serenity is tripped and tim or sarah’s phone is tripped within say 5 minutes or so.
I just can’t get it to work.

Please help me with the proper syntax so I can understand.

PS. I hate captchas. It never takes me less than 3 tries to figure them out.

Try Sequence Expressions. For the WiFi issue try to use PLEG to see if the signal is gone (NoPingTim) and has been gone for more than X minutes: My iPhone returns a ping at least every 8 minutes (if it is on, not in airplane mode or battery not dead) so I can use 20mins.

Input:
PingSensorTim (Sensor indicates Present)

Condition

NoPingTim = !PingSensorTim
TimIsGone = NoPingTim and (NoPingTim>20:00)

Action
TimIsGone (shut off the light)

Or you can do this in one condition with the following:

TimIsGone = !PingSensorTim and (!PingSensorTim; NOW > 20:00)

[quote=“RichardTSchaefer, post:3, topic:180628”]Or you can do this in one condition with the following:

TimIsGone = !PingSensorTim and (!PingSensorTim > 20:00)[/quote]

Richard, I use … !AaronPhone AND (!AaronPhone; NOW > 3:00)

What is the difference vs if I used… !AaronPhone AND (!AaronPhone > 3:00)

?

Thanks for the help guys.
I’m getting an invalid value token when I do that Richard.

I think I’ve got it working without using PLEG, it’s sort of kludgy, but I think it will work.
If vera detects the garage sensor open, I have it set to arm the ping sensor for the phones
If the ping sensor is armed, and tripped after a 5 minute delay it locks the door and turns off the lights.
When the door is locked it disarms the ping sensor.

Anyone see anything wrong with that logic? It seems to work so far in my limited testing.

[quote=“prim8, post:5, topic:180628”]Thanks for the help guys.
I’m getting an invalid value token when I do that Richard.

I think I’ve got it working without using PLEG, it’s sort of kludgy, but I think it will work.
If vera detects the garage sensor open, I have it set to arm the ping sensor for the phones
If the ping sensor is armed, and tripped after a 5 minute delay it locks the door and turns off the lights.
When the door is locked it disarms the ping sensor.

Anyone see anything wrong with that logic? It seems to work so far in my limited testing.[/quote]

that will work fine IMO - though, I’m not seeing why you’d arm/disarm Ping? I like having my Ping be able to “see” I’m home before I pull into the garage. I have it automatically disarm my Security Alarm before I open the garage (I also use Tasker to tell the system I’m home when I pull onto the street) - so I have 2 methods as a failsafe. BTW, is you decide to add a garage motion sensor, which I have, you are going to want to disable your Alarm (if you have one) before the motion sensor sees the garage opening :wink:

[quote=“RichardTSchaefer, post:3, topic:180628”]Or you can do this in one condition with the following:

TimIsGone = !PingSensorTim and (!PingSensorTim > 20:00)[/quote]
Am I correct to assume that when I get an invalid token, it’s a spelling error of some kind on my part between the inputs and references to them in the condition?

Looking at the status of the PLEG using Richard’s condition, the condition never moves to true. edit Once I removed the time requirement of the expression, I am able to make it turn true. I’m going to do a little more fiddling with it and see if I can figure out why it’s not triggering a true when there is a time requirement.
edit As soon as I add the time requirement back in, I’m getting an invalid value token error. I don’t understand it, I pasted in exactly what you typed, which didn’t give me an error before (it just never turned true) but now it’s giving me an error.

I’m using “arm” and “bypass” as a second trigger in scenes since vera isn’t setup to use the “and” expression.

Oops … i meant:

TimIsGone = !PingSensorTim and (!PingSensorTim; NOW > 20:00)

That worked, thank you.
So, to be sure I’m understanding correctly; in plain language:
PingSensorTim is not tripped and not tripped from 20 minutes of initial timestamp, TimIsGone will be true?

You got it!

But I would say:
PingSensorTim is not tripped and not tripped from 20 minutes of the most recent timestamp
… or in other words:
PingSensorTim is not tripped and has not been tripped for over 20 minutes.

Thanks for your help, I really appreciate it.
I’m still working on my original goal because I truly do want to learn this.

So, what I’ve done so far is create Inputs for:
CrvGarage when the sensor on that door is tripped.
SerenityGarage when the sensor on that door is tripped
PingSensorSarah when her phone is tripped (I have the ping sensors set to inverted)
PingSensorTim when my phone is tripped

For conditions so far what I have is:
TimIsGoneSerenity = PingSensorTim and SerenityGarage and (SerenityGarage, PingSensorTim < 1:00)
I want to it to be true when the garage door opens and my phone is tripped. I have it set for just a minute for testing purposes. I’ll likely increase that some later to account for everyone getting in the car.
SarahIsGoneCrv = PingSensorSarah and CrvGarage and (CrvGarage, PingSensorSarah < 1:00)

TimIsGoneCrv = PingSensorTim and CrvGarage and (CrvGarage, PingSensorTim < 1:00)

SarahIsGoneSerenity = PingSensorSarah and SerenityGarage and (SerenityGarage, PingSensorSarah < 1:00)

Right now I have this just turning on a light for testing but later I want it to lock a door and turn off a couple of lights. I also want to look into checking if the garage doors are closed and notifying me if they aren’t.

Does this all look right so far? I’m not getting any errors and I was able to test TimIsGoneSerenity and it seems to work. I can’t test PingSensorSarah until I have my wife’s phone.
Have I done this appropriately, or is there a way to combine these into one expression to be more efficient?

There are a couple of problems:

  1. SerenityGarage, PingSensorTim < 1:00)

This is true when the two events happen within 1 minute of each other (unordered sequence expression).
I do not know how often the ping sensor fires … but if it does not fire within the 1 minute … there will be a problem.

  1. Often Ping gets get a false hit … they indicate not there when you are … That’s because smart phones sometimes are sleeping when the ping hits.

Thank you,
I have it set to 1 minute just for testing it for right now. I’ll change the time to be something more appropriate, probably around 10 minutes.
I’m clumsily treating the ping sensor as a motion sensor and the garage door as our exterior door because I don’t have any motion sensors yet and we virtually always leave through the garage.
I’m trying to go for a wasp in a box algorithm. [url=http://www.dreamgreenhouse.com/projects/2013/presence/#wasp]Stylish and environmental smart home design & build
The Ping Sensors are the buzzing, and the garage door is the lid on the box.
The ping having false hits is why I wanted to add another trigger like the garage door being open.

You should have at least two pings within the time interval you set for the conditions.

So if you use 10 minutes … your Ping interval should probably be 5 minutes or less.

Are you talking about the Ping Sensor poll period? It’s set to 15 seconds.
Or are you saying that I should have and expression somehow checking the PingSensorTim twice. I’ll have to figure that out because I haven’t the faintest clue.

YEP … that’s what I was talking about.

Thank you, I truly appreciate you helping me understand all this.

I’ve made some changes that I believe will further reduce false positives caused by the occasional loss of network by my phone.
The goal of this PLEG is for me to run something when either my phone, or my wife’s is off network for some time as well as one of the two garage doors opening within a certain time.

I have attached the report from this PLEG for anyone interested.

Feel free to critique of there’s something that is wrong or could be done better.

Thank you RichardTSchaefer, Aaron, Bulldoglowell for your help in this thread.
Thank you RichardTSchaefer for the plugin.
Thank you RexBeckett for PLEGBasics http://forum.micasaverde.com/index.php/topic,21603.0.html
and thank you to everyone else that posts here because I’ve been trying to read as much of it as I can while trying to get ideas and understand it all.