Auto lock door only after door is closed using PLEG

Ok So I HAVE READ SOME STUFF ON THIS EXACT idea using PLEG. Seems like it would be easy enough to understand, however I am confused when I get in PLEG in the vera website. Could anyone walk me through how to set up what I want. I think I could understand it better and start incorporating this into my Vera devices if I start from scratch… First of all thank you for being patient. Second, thank you for taking your valuable time to help a fellow Vera user out. I am using vera plus and ui7. I have a Kwikset door lock called front door lock and a Fibaro door sensor called front door sensor. (fgdw-002). I want to keep the door from locking when the sensor is in the open status. And also lock the door every 10 minutes or so. I have scenes running the 10 minute check and locks the doAlthough it doesnt check when the door was last opened. It would be great to start using PLEG to do this check. Honestly I changed it to an hour because I was annoyed when my gf would go out and smoke it would lock her out and she would hit the buttons to open it. This kills the battery on the lock. Any help would be awesome.

Have you read the getting started guide?

Sent from my SAMSUNG-SM-G935A using Tapatalk

It took me sometime to understand PLEG also, I never fully understood it on my old system with UI5, but it got hit by lightning and I got a new Plus with UI7 and had to do everything from scratch.

Under Logic Inputs -> Device Triggers

Create 2 device triggers

Trigger 1 (door lock)
Trigger Name - tFrontDoorUnlocked
Trigger Device - Select your front door lock
Event Type - A door is locked or unlocked
Which mode - Device is opened

Trigger 2 ( door open/close sensor)
Trigger Name - tFrontDoorClosed
Trigger Device - Select your front door open/close sensor
Event type - Whenever Device is closed whether is armed or disarmed

Under Conditions (Automatic Logic)

Create 1 new condition

Condition Name - cFrontDoorUnlockedClosed
Option - Repeats on
Syntax

tFrontDoorUnlocked and tFrontDoorClosed and ( tFrontDoorClosed;NOW > 00:03:00 ) and ( tFrontDoorUnlocked;NOW > 00:03:00 )

Click save

This means whenever the door lock is unlocked for greater than 3 minutes and the door has been shut for greater than 3 minutes.

Under logic actions

Click dropdown for Select New Action and choose cFrontDoorUnlockedClosed
Click dropdown for Select Device to Add to the Current Interval and select your front door lock
Turn off advanced
Toggle the front door lock to the locked setting
Click Save

Now click on Editor Option in the top right and click on Reload LUA and then close.
Watch the top of the browser window for any PLEG errors while it reloads.
Test

[quote=“RichardTSchaefer, post:2, topic:197207”]Have you read the getting started guide?

Sent from my SAMSUNG-SM-G935A using Tapatalk[/quote]
Richard reading the 20 PLus pages now :stuck_out_tongue_winking_eye:

It took me sometime to understand PLEG also, I never fully understood it on my old system with UI5, but it got hit by lightning and I got a new Plus with UI7 and had to do everything from scratch.

Under Logic Inputs -> Device Triggers

Create 2 device triggers

Trigger 1 (door lock)
Trigger Name - tFrontDoorUnlocked
Trigger Device - Select your front door lock
Event Type - A door is locked or unlocked
Which mode - Device is opened

Trigger 2 ( door open/close sensor)
Trigger Name - tFrontDoorClosed
Trigger Device - Select your front door open/close sensor
Event type - Whenever Device is closed whether is armed or disarmed

Under Conditions (Automatic Logic)

Create 1 new condition

Condition Name - cFrontDoorUnlockedClosed
Option - Repeats on
Syntax

tFrontDoorUnlocked and tFrontDoorClosed and ( tFrontDoorClosed;NOW > 00:03:00 ) and ( tFrontDoorUnlocked;NOW > 00:03:00 )

Click save

This means whenever the door lock is unlocked for greater than 3 minutes and the door has been shut for greater than 3 minutes.

Under logic actions

Click dropdown for Select New Action and choose cFrontDoorUnlockedClosed
Click dropdown for Select Device to Add to the Current Interval and select your front door lock
Turn off advanced
Toggle the front door lock to the locked setting
Click Save

Now click on Editor Option in the top right and click on Reload LUA and then close.
Watch the top of the browser window for any PLEG errors while it reloads.
Test[/quote]
OK thank you for this. It was unclear if these were names needed in order for Pleg and vera to communicate ( tFrontDoorUnlocked , tFrontDoorClosed,cFrontDoorUnlockedClosed) but I see now they are names I am calling and can name these anything I want probably as long as the t(trigger) and c(condition) are in front of the name. The t and c maybe just for ease of knowing which is which (Simplification) but I will continue to put them anyway just in case they are needed.
I will go over this and then implement it to test. THANK YOU V much. I will also finish reading the beginners guide to PLEG to get some more understanding.

[quote=“michaelhinchey, post:5, topic:197207”]OK thank you for this. It was unclear if these were names needed in order for Pleg and vera to communicate ( tFrontDoorUnlocked , tFrontDoorClosed,cFrontDoorUnlockedClosed) but I see now they are names I am calling and can name these anything I want probably as long as the t(trigger) and c(condition) are in front of the name. The t and c maybe just for ease of knowing which is which (Simplification) but I will continue to put them anyway just in case they are needed.
I will go over this and then implement it to test. THANK YOU V much. I will also finish reading the beginners guide to PLEG to get some more understanding.[/quote]

The t prefix is just that, a prefix to remind you that it is a Trigger, similarly c = Condition, p= Property and so on. There is no need for them apart from the ease of remembering what they are.

…and in case you have a property, trigger, and/or condition with the same name.

[quote=“zedrally, post:6, topic:197207”][quote=“michaelhinchey, post:5, topic:197207”]OK thank you for this. It was unclear if these were names needed in order for Pleg and vera to communicate ( tFrontDoorUnlocked , tFrontDoorClosed,cFrontDoorUnlockedClosed) but I see now they are names I am calling and can name these anything I want probably as long as the t(trigger) and c(condition) are in front of the name. The t and c maybe just for ease of knowing which is which (Simplification) but I will continue to put them anyway just in case they are needed.
I will go over this and then implement it to test. THANK YOU V much. I will also finish reading the beginners guide to PLEG to get some more understanding.[/quote]
THANKS for the info. I will start reading after the weekend. Im so very interested in this. I hear there is an app being redone for android that incorporates pleg into it. Iphone already has this in place. Any one with an iphone care to comment how this makes it easier?

The t prefix is just that, a prefix to remind you that it is a Trigger, similarly c = Condition, p= Property and so on. There is no need for them apart from the ease of remembering what they are.[/quote]

I dont get any errors while reloading the engine however when I rm the PLeg device it reads this error Trigger Description error: TypeError: Cannot read property ‘value’ of undefined
Any ideas?

It took me sometime to understand PLEG also, I never fully understood it on my old system with UI5, but it got hit by lightning and I got a new Plus with UI7 and had to do everything from scratch.

Under Logic Inputs -> Device Triggers

Create 2 device triggers

Trigger 1 (door lock)
Trigger Name - tFrontDoorUnlocked
Trigger Device - Select your front door lock
Event Type - A door is locked or unlocked
Which mode - Device is opened

Trigger 2 ( door open/close sensor)
Trigger Name - tFrontDoorClosed
Trigger Device - Select your front door open/close sensor
Event type - Whenever Device is closed whether is armed or disarmed

Under Conditions (Automatic Logic)

Create 1 new condition

Condition Name - cFrontDoorUnlockedClosed
Option - Repeats on
Syntax

tFrontDoorUnlocked and tFrontDoorClosed and ( tFrontDoorClosed;NOW > 00:03:00 ) and ( tFrontDoorUnlocked;NOW > 00:03:00 )

Click save

This means whenever the door lock is unlocked for greater than 3 minutes and the door has been shut for greater than 3 minutes.

Under logic actions

Click dropdown for Select New Action and choose cFrontDoorUnlockedClosed
Click dropdown for Select Device to Add to the Current Interval and select your front door lock
Turn off advanced
Toggle the front door lock to the locked setting
Click Save

Now click on Editor Option in the top right and click on Reload LUA and then close.
Watch the top of the browser window for any PLEG errors while it reloads.
Test[/quote]

I dont get any errors while reloading the engine however when I rm the PLeg device it reads this error Trigger Description error: TypeError: Cannot read property ‘value’ of undefined
Any ideas?

Sounds like it was expecting a number or character and it found a character or number.

[quote=“michaelhinchey, post:10, topic:197207”]I dont get any errors while reloading the engine however when I rm the PLeg device it reads this error Trigger Description error: TypeError: Cannot read property ‘value’ of undefined
Any ideas?[/quote]

You will have to show us what you have in PLEG so we can help.

[quote=“gibby, post:12, topic:197207”][quote=“michaelhinchey, post:10, topic:197207”]I dont get any errors while reloading the engine however when I rm the PLeg device it reads this error Trigger Description error: TypeError: Cannot read property ‘value’ of undefined
Any ideas?[/quote]

You will have to show us what you have in PLEG so we can help.[/quote]

Usually this is done by posting a Status Report PDF. Sample attached.

[quote author=Don Phillips link=topic=50888.msg330387#msg330387 date=1506385415]

[quote=“gibby, post:12, topic:197207”][quote=“michaelhinchey, post:10, topic:197207”]I dont get any errors while reloading the engine however when I rm the PLeg device it reads this error Trigger Description error: TypeError: Cannot read property ‘value’ of undefined
Any ideas?[/quote]

You will have to show us what you have in PLEG so we can help.[/quote]

Usually this is done by posting a Status Report PDF. Sample attached.
[/quote
Wow that pdf is intimidating.Lots of expert Pleg Coding there/ IM unsure how to get a pdf file. I tried exporting a file but it doesnt allow me to see it. Any help?

Lots of trial and error - especially the error.

Once your status report window pops up, I use a free PDF printer. Here is a screenshot.

In PLEG under Editor Option, click on logic report. That is what we need.

I find the status report more helpful than the logic report since you can see when conditions are last true.

Just throwing this idea out there-- could you achieve your overall goal through a simple scene? Here’s what I’m thinking.

I like the idea of it doing a “lock check” every 10 mins or so. It would be a good way to make sure that your door was locked again, in case it was randomly unlocked.

But thinking about my personal habits, any time I unlock my door, I always close it after that. It’s never hanging open.

What if “closed door” is a better and easier trigger to use? A scene that said “any time the door is closed, the door will lock X minutes later” might achieve what you’re looking for.

Just a shot in the dark :slight_smile:

A corollary to that idea is one I use for my garage door. When it opens, I get a notification (and it triggers an iPhone check). If left open for more than 10 minutes, I get a notification every 10 minutes that it is still open. Sometimes we forget to close it. Rarely, the sensor does not know it is closed, so it reminds me to clear that error (by opening and then closing the door via Vera).

That could work for the door locks. Either locks them after 10 minutes or sends you a notification so you can manually (either physically or using Vera) lock the lock. Or investigate since something may be up.

A door lock with a sensor makes this even better. If the door is left open, no sense locking the lock, but certainly notify would be appropriate.

And the logic could be tied to House Mode. A door left open/unlocked in Away Mode probably needs to be treated differently than when in Home Mode.

Lastly, with unique pin codes, if family opens the door, you likely need difference lock treatment than when a handyman enters when you do not expect them.

Nice one Don! …but how do you get the alert to repeat every 10 minutes?
Thanks!