Arming/Disarming Security Sensors Using PLEG & iPhone Locater Plugins

Hi guys,

I know I have seen random posts on this topic before in different threads, but I am trying to set up a PLEG to arm & disarm my security sensors (which are connected to a z-wave siren) based on various conditions using the iPhone Locater Plugin. My main issue is getting the logic in PLEG to do things based on one of three conditions: 1) Myself and my girlfriend are both not present in the house so the security sensors should arm, 2) Myself OR my girlfriend are present in the house so the security sensors should remain in the bypassed state and 3) Myself AND my girlfriend are home so the security sensors should remain in the bypassed state. So far, the iPhone Locator plugin on its own is working great - when I am away, or my girlfriend is away, the sensors arm. When either one of us returns to the house, the sensors switch back to their bypassed state. The PLEG however is not working based on the logic I’ve inputed, so obviously I’ve screwed up somewhere. When I am home, but my girlfriend is away, the security sensors still switch to their armed state – Obviously not what I want to have happen. Can someone take a look at my PLEG status report and see what I’ve done wrong? Thanks!

[Code]
PLEG Alarm Control

Device ID: 992014-01-28 19:42:20.455 PLC Version: 5.7

Triggers

Name Description State Last True Last False
TAlexHome ()Alex's iPhone is present true 2014-01-28 18:41:24.330 2014-01-28 18:41:22.283
TAlexAway (
)Alex's iPhone is away false 2014-01-28 18:41:22.283 2014-01-28 18:41:24.330
TLauraHome ()Laura Fornaro?s iPhone is present false 2014-01-28 18:56:43.847 2014-01-28 18:56:50.129
TLauraAway (
)Laura Fornaro?s iPhone is away true 2014-01-28 18:56:50.129 2014-01-28 18:56:43.848

Conditions

Name Expression State Last True Last False
CNobodyHome TAlexAway AND TLauraAway false 0 0
CSomeoneHome NOT CNobodyHome true 2014-01-28 18:41:24.333 2014-01-28 18:41:22.288
CEveryoneHome TAlexHome AND TLauraHome false 2014-01-28 18:56:43.854 2014-01-28 18:56:50.132
Actions

Actions for Condition: CNobodyHome

Immediate

Device Action Arguments
Basement Door SetArmed newArmedValue=1
Basement Window Left SetArmed newArmedValue=1
Basement Window Middle SetArmed newArmedValue=1
Basement Window Right SetArmed newArmedValue=1
Camera - Basement Motion Sensor SetArmed newArmedValue=1
Half Bath Window SetArmed newArmedValue=1
Laundry Room Light SetLoadLevelTarget newLoadlevelTarget=0
Master Bedroom Light SetLoadLevelTarget newLoadlevelTarget=0
Office Window Left SetArmed newArmedValue=1
Office Window Right SetArmed newArmedValue=1
Kitchen Door SetArmed newArmedValue=1
Kitchen Window Left SetArmed newArmedValue=1
Bay Window Left 1 SetArmed newArmedValue=1
Bay Window Left 2 SetArmed newArmedValue=1
Bay Window Right 1 SetArmed newArmedValue=1
Bay Window Right 2 SetArmed newArmedValue=1
Camera - Living Room Motion Sensor SetArmed newArmedValue=1
Front Door Light SetTarget newTargetValue=1
Front Door Lock SetTarget newTargetValue=1

Actions for Condition: CSomeoneHome

Immediate

Device Action Arguments
Basement Door SetArmed newArmedValue=0
Basement Window Left SetArmed newArmedValue=0
Basement Window Middle SetArmed newArmedValue=0
Basement Window Right SetArmed newArmedValue=0
Camera - Basement Motion Sensor SetArmed newArmedValue=0
Half Bath Window SetArmed newArmedValue=0
Office Window Left SetArmed newArmedValue=0
Office Window Right SetArmed newArmedValue=0
Kitchen Door SetArmed newArmedValue=0
Kitchen Window Left SetArmed newArmedValue=0
Kitchen Window Right SetArmed newArmedValue=0
Bay Window Left 1 SetArmed newArmedValue=0
Bay Window Left 2 SetArmed newArmedValue=0
Bay Window Right 1 SetArmed newArmedValue=0
Bay Window Right 2 SetArmed newArmedValue=0
Camera - Living Room Motion Sensor SetArmed newArmedValue=0
Front Door SetArmed newArmedValue=0[/Code]

It look like you changed the name of Conobodyhome and it has not been set yet. It should sync up when both are gone.

The logic looks good. Now that I record on and off time stamps you can get rid of half of the triggers and use the not operator in your conditions.

@RichardTSchaefer:

Thanks for the reply. So in order for all the conditions to fire they first all have to be met to sync up? So far the only condition I’ve met is one of the iPhones are present. That’s the condition I thought would be able to fire seeing as only one iPhone is present now but if I understand you correctly I have to first meet the criteria for CNobodyHome (having both iPhones leave the house) and then everything will sync up? I’m so new to PLEG so I apologize if I totally mis-understood you there.

Also, what is your thoughts on PLEG and Vera’s built-in scene scripting? If I eventually become fairly adept at using PLEG should I remove all my current Vera-scripted scenes and move them all to PLEG or do you think that’s unnecessary and I should use PLEG for more complicated scene scripting but leave the simpler stuff to Vera?

The down side of PLEG at this moment is that it does not work with UI6.
But that’s only 1 thing in a large list of things that do not work there … including most 3rd party smart phone apps.

I generic Scene with LUA code would probaby run on UI6.

When my girlfriend left the house this morning, the sensors all armed even though I was still home. I later disarmed the basement door, left home (which was sensed) and all the sensors armed which is what I wanted (no one home = arm all sensors). When I returned home but my girlfriend was still out, the sensors disarmed for me as I wanted and the sensors will likely all disarm when my girlfriend gets home as well. But what is to prevent the same issues from happening later when one of us leaves and the other is home? Is my logic flawed with the way I set it up or now that all the conditions synched it should work properly if one of us leaves but the other remains home?

Your logic should be OK provided the iPhone locator is giving you reliable results. If you get another unexpected arming, pull the Status report from PLEG so you can see why it happened.

You could also enable PLEG’s Debug logging to a Standalone file (click the Log button). This will allow you to look back after the event.

I copied the PLEG as posted by agoodman82. it worked the first time and armed all my sensors. afterwards, even if my wife and i are home, the iphones still indicate “away”. is it because it says “you are not licensed”. can someone please take a look at my status report below. thanks.

PLEG-Arm-Disarm All Sensors
Device ID: 1272014-05-08 11:55:31.289 PLC Version: 6.7
Registration
You are not licensed!
Triggers
Name Description State Last True Last False
EdnaAway ()Edna's iPhone is away false 0 0
EdnaHome (
)Edna's iPhone is present false 0 0
RenatoAway ()Renato's iPhone is away true 2014-05-04 20:33:20.000 2014-05-04 20:33:20.000
RenatoHome (
)Renato's iPhone is present false 2014-05-04 20:33:20.000 2014-05-04 20:33:20.000
Conditions
Name Repeat Expression State Last True Last False
NobodyHome No RenatoAway AND EdnaAway false 0 0
SomeoneHome No NOT NobodyHome true 2014-04-30 16:33:20.000 0
EveryoneHome No RenatoHome AND EdnaHome false 0 0
Actions
Actions for Condition: NobodyHome
Device Actions:
Immediate
Device Action Arguments
Away Switch SetTarget newTargetValue=1
Basement Door Sensor SetArmed newArmedValue=1
SM103-Window Sensor-Bath Upstairs SetArmed newArmedValue=1
Window Sensor-PC SetArmed newArmedValue=1
SM103- Window Sensor-Emma SetArmed newArmedValue=1
SM-103 Door Sensor-Back Door SetArmed newArmedValue=1
Door Sensor-Ecolink SetArmed newArmedValue=1
Motion Sensor-Z1R000 SetArmed newArmedValue=1
_Kwikset Door Lock SetTarget newTargetValue=1
Sensor-Front Door SetArmed newArmedValue=1
Actions for Condition: SomeoneHome
Device Actions:
Immediate
Device Action Arguments
Away Switch SetTarget newTargetValue=0
SM103-Window Sensor-Bath Upstairs SetArmed newArmedValue=0
Window Sensor-PC SetArmed newArmedValue=0
SM103- Window Sensor-Emma SetArmed newArmedValue=0
SM-103 Door Sensor-Back Door SetArmed newArmedValue=0
Door Sensor-Ecolink SetArmed newArmedValue=0
Motion Sensor-Z1R000 SetArmed newArmedValue=0
Sensor-Front Door SetArmed newArmedValue=0
Basement Door Sensor SetArmed newArmedValue=0

The Free license allows 3 PLEGs each with a maximum of 5 inputs and 5 conditions. This falls within limits as long as you do not have more than two other PLEG or PLTS devices.

It looks like Edna’s phone is not setup properly … there has never been any events from it … not the last true and last false time are 0.
Also Renato’s phone has been away since: 2014-05-04 20:33:20.000.

The logic looks find … the inputs just don’t seem to be firing.
Have you uninstalled/reinstalled the IPhone locator plugin ? Maybe these triggers are pointing to removed devices.

[quote=“RichardTSchaefer, post:8, topic:179142”]The Free license allows 3 PLEGs each with a maximum of 5 inputs and 5 conditions. This falls within limits as long as you do not have more than two other PLEG or PLTS devices.

It looks like Edna’s phone is not setup properly … there has never been any events from it … not the last true and last false time are 0.
Also Renato’s phone has been away since: 2014-05-04 20:33:20.000.

The logic looks find … the inputs just don’t seem to be firing.
Have you uninstalled/reinstalled the IPhone locator plugin ? Maybe these triggers are pointing to removed devices.[/quote]

That’s what I remember in your post; 3 PLEGs free and 5 inputs and 5 conditions in each PLEG. I only have 2 PLEGS. I have unistall and reinstall the phone locator plugin once. i will do it again. thanks for your response.

You may need to delete the triggers and re-recreate them … they may be pointing to OLD devices that you have deleted.

Now it is arming all my sensors after following your suggestions; the problem is even if we are home the plugin still shows “away”. when i force-click “present”, it will stay only for about 10 seconds and goes back to “away” status. can you please look at the attached report. thanks for your help.

Doing a status report after you type in new triggers and conditions is usually meaningless … You need to exercise your input triggers to make sure they are working properly …

i.e. you need to make the phones go away then come back … than you can see the effect on the logic using the status report.

PLEG is event driven … nothing changes if there are no input events …

FYI … you can delete two of the inputs. … i.e. you can get rid of the home inputs because:
EdnaHome = !EdnaAway
or
EdnaHome = Not EdnaAway

The ! is a shorthand for NOT.

[quote=“RichardTSchaefer, post:12, topic:179142”]Doing a status report after you type in new triggers and conditions is usually meaningless … You need to exercise your input triggers to make sure they are working properly …

i.e. you need to make the phones go away then come back … than you can see the effect on the logic using the status report.

PLEG is event driven … nothing changes if there are no input events …

FYI … you can delete two of the inputs. … i.e. you can get rid of the home inputs because:
EdnaHome = !EdnaAway
or
EdnaHome = Not EdnaAway

The ! is a shorthand for NOT.[/quote]

I see what your are saying about the status report and you are right. We went to NJ last night-iphones are “away” and when i woke up this morning they are both “present”. thanks for this. however, i don’t seem to follow what you said to get rid of the 2 “home” inputs. do you mean get rid of the input EdnaHome and RenatoHome as per attached screenshot. Sorry for my ignorance, i am not too good at this PLEG.

You do not have to get rid of them … but you can if you want … Your on the free version and if you wanted to stay within the 5 input limit you could remove two of your inputs.

Given the pairs (EdnaAway and EdnaHome) and (RenatoAway and RenatoHome).

You can get rid of one from each pair … it does not matter which one.
In your condition expression you replace DeletedInput with NOT KeptInput

[quote=“RichardTSchaefer, post:14, topic:179142”]You do not have to get rid of them … but you can if you want … Your on the free version and if you wanted to stay within the 5 input limit you could remove two of your inputs.

Given the pairs (EdnaAway and EdnaHome) and (RenatoAway and RenatoHome).

You can get rid of one from each pair … it does not matter which one.
In your condition expression you replace DeletedInput with NOT KeptInput[/quote]

(1) got rid 2 of the 4 home inputs
(2) condition expression: i don’t have a DeletedInput to replace with NOT KeptInput. shall i create one? sorry, i as said i’m not good at this PLEG thing.
(3) i am home right now-when i click the unmute button, iphones go to “away” status" arming all the sensors.

In your case:
KeptInput is RenatoHome (for one pair) and EdnaHome (for the second pair)
and
DeletedInput is RenatoAway (for one pair) and EdnaAway (for the second pair)

So you would change the condition (NobodyHome) that refeferenced RenatoAway and EdnaAway to the following:

NobodyHome (NOT RenatoHome) and (NOT EdnaHome)

[quote=“RichardTSchaefer, post:16, topic:179142”]In your case:
KeptInput is RenatoHome (for one pair) and EdnaHome (for the second pair)
and
DeletedInput is RenatoAway (for one pair) and EdnaAway (for the second pair)

So you would change the condition (NobodyHome) that refeferenced RenatoAway and EdnaAway to the following:

NobodyHome (NOT RenatoHome) and (NOT EdnaHome)[/quote]

ok got you. did just that. like what you said, i have to exercise the new input triggers - make the iphones go away and then comeback. thanks and i will report back. really appreciate your help. i like deleting the pair of input triggers to minimize clutters.

How can I do this using normal scenes on vera? (or advanced editor) Not too comfortable with pleg.

Using scenes (before I bit the bullet and learned PLEG), I used 2 virtual switches and a combination switch.

The virtual switch was turned on by iPhone Locator for each person (we have 2, yay to empty nesters).

The combination switch NoOneHome would turn on when both of the virtual switches were off and when on, a scene changed the House Mode to Away and arm the cameras by sending a wget to Blue Iris. If either of us got home, the combination switch would turn off and a scene would change the House Mode to Home and disarm the cameras.