PLEG and iPhone Locator Muting

@shmixx
Good eye … I did not notice that!

I think I see what you’re saying. Do you guys have any suggestions for a better check? I had copied this logic from someone else. I need some kind of trigger to unmute the Locator and I figured opening the garage was the best way since it’s the way I leave the house most often. I don’t have any other zwave locks/sensors to trigger.

Maybe:
CPhoneMute TScottHome1 AND (TScottHome1; Now > 5:00) AND (CPhoneUnMute; Now > 5:00)

Let the Garage unmute as it currently does …
But the above will mute the phone 5 minutes after it is unmuted … as long as TScottHome1 is true.

Thanks I’ll see how that works!

@cubs

I think you may need to think what the goal is. I believe with RichardT’s suggestion, you would need to be home, have been home for 5 minutes, and need to have triggered the unmute condition followed by another 5 minutes, before the condition would then become true.

I placed mine similar but in 2 separate conditions:

CPhoneMute1: TShawnHome AND (TShawnHome; Now > 5:00)
CPhoneMute2: TShawnHome AND (CPhoneMuteOff; Now > 5:00)
CPhoneMuteOff: TFrontDoor OR TGarageDoor OR TArmed (basically these are just any sensor being tripped for the doors)

This essentially will ensure that only when I’m home (TShawnHome) will the phone mute. It will do so either after 5 minutes of TShawnHome becoming true after previously being false (aka away), or after 5 minutes of UnMuting if I’m still home. The reason I don’t put a logical OR in the statement, is then it becomes true when I first come home, but stays true even after UnMuting, thus ending in the same situation you described above. I think I actually put in the same logic my first time around. :wink:

Ahh now I know who to blame :wink:

I think it’s working the right way with the AND in there. I can always break it up as you did if that proves to fail in a particular case. I’ve now realized that I’m not nearly as quick getting out of the house in the mornings (or if my wife has left first and left the garage open) so really I’m needing to set it closer to 30 minutes.

@cubs - I was thinking you may have used my intial condition based on the naming convention. :wink:

I think if you were to break it up that might solve your timing problem. My thought process, was that if I open the garage door, I’m generally in the car and gone within 5 minutes. Then the phone should Mute again. But if the door is tripped again, then unmute for another 5 minutes to see if I leave.

Keep in mind, my GarageDoor trigger, isn’t the actual garage door itself, it’s the door leading out the house into the garage. I leverage the alarm sensor to trip this one. If using the actual GarageDoor, perhaps you want to use both an open/close state as triggers? This would allow the action of closing your wife’s garage as you notice when leaving yourself (or closing the single double bay door) to trigger evaluation of the condition as well. This will unmute your phone in that situation to notice your departure.

With the split setup I used, my phone will mute when I’m home for more than 5 minutes. The second mute condition, is to throw it back on mute as long as I’m still home after 5 minutes of the door to the garage being tripped. So my phone stays muted when I’m home and no doors trip, unmute for 5 minutes when a door is tripped, and then mutes again if I’m not seen as away within 5 minutes.

Depending on your distance for “present” in the iPhone plugin and how long it takes to break that barrier from the time the trigger is actually triggered, perhaps bumping to 10 minutes or so will help.

@shmixx,

Aweseome reply. Thanks for that! I like the idea of triggering off both the open and close. I know I’ve seen people have conditions where you look at a sequence of events. I’m really new to the PLEG syntax so do you have any suggestions?

@cubs

Based on your use, it’s not much more difficult to add an additional OR clause for the open/close triggers. The difference in your case is that your actual garage door(s) go up and down. My door sensor is simply a trip when opened, and usually closed momentarily after. So I don’t worry about 2 states, in your case creating a trigger for open and a trigger for closed. As I think through the logical layout making use of the _ function may be valuable here since you will have a condition stay true in some instances. My suggestion below:

TRIGGERS
TGarageO - Garage door is open
TGarageC - Garage door is closed
TScottHome - Scott (iOS) is present
TScottAway - Scott (iOS) is away

CONDITION
CPhoneMute1 - TScottHome AND (TScottHome; NOW > 5:00)
CPhoneMute2 - TScottHome AND (_CPhoneMute; NOW > 5:00)
_CPhoneUnmute - TGarageO OR TGarageC OR TScottAway

From here, obviously assign the actions in line with the mute/unmute of the iOS locator plugin. This mimics the setup I’m using now, but adds in logic to re-evaluate the unmuting any time the garage door is opened or closed, or if you magically appear away (manual intervention, testing ,etc). It will also ensure that once CPhoneMute2 becomes untrue when you open one of the garage doors or close them, then it will re-evaluate the 5 minute timer and mute the device accordingly.

I apologize if this is sloppy or missing details, actually in the car. Let me know how this works out though if you test it out. I’ve never used the _ function before, but theoretically it should help in this situation as needed for the logic to evaluate properly.

@shmixx

Thank you for your explanation here - I was struggling for a long time before I found this thread.

Thanks a million.

Hi guys,

I stumbled upon this thread and although I tried to follow the instructions here I am completely new to PLEG. I am attempting to mute my iPhone locator plugin to save battery life while I’m at home. Can someone take a look at my logic and tell me what I’m doing wrong? Even though I’m home and my PLEG plugin is set to “arm” I can’t get the PLEG plugin to show I’m “home” in the report.

Triggers

Name Description State Last True Last False
TAlexHome ()Alex's iPhone is present false 0 0
TAlexAway (
)Alex's iPhone is away false 0 0
TLauraHome ()Laura Fornaro?s iPhone is present false 0 0
TLauraAway (
)Laura Fornaro?s iPhone is away false 0 0
TBasementDoor Basement Door is tripped false 2014-01-26 11:52:12.704 2014-01-26 11:52:18.384
TFrontDoor Front Door is tripped false 2014-01-25 15:08:21.699 2014-01-25 15:08:37.049
Conditions

Name Expression State Last True Last False
CPhoneMute TAlexHome AND ((TAlexHome; Now > 1:00) OR (CPhoneMute; Now > 1:00)) false 0 0
CPhoneUnmute TFrontDoor OR TBasementDoor OR TAlexAway false 2014-01-26 11:52:12.721 2014-01-26 11:52:18.411
Actions

Actions for Condition: CPhoneUnmute

Immediate

Device Action Arguments
(*)Alex's iPhone SetMute newMuteStatus=0
Actions for Condition: CPhoneMute

Immediate

Device Action Arguments
(*)Alex's iPhone SetMute newMuteStatus=1

@agoodman

Looks like your iPhone locator isn’t triggering you as away or home. Not sure what you set the variables to be, but I would verify you didn’t select the same item from the drop down when creating the trigger. If that is all good, I would verify your iPhone locator plugins are working correctly as it seems you aren’t picking up a true/false. If you just installed the plugins, then set this PLEG up, then looked for it, it may simply be that the iPhone locator triggers haven’t actually changed yet. Simply try clicking on the away/home button on the plugin to kick it into motion. Then try opening/closing one of the doors to trigger CPhoneMute or CPhoneUnmute conditions. This should kick the loop into play.

Thanks for the advice shmixx,

You were correct that it was an issue with the iPhone locator plugin. I had to manually tell the plugin I was present, then fired away, and then based on my location it automatically changed back to present, which kicked the PLEG mute/unmute plugin into action.

Here’s a new question though. Now my logic tells PLEG that when I trip the front or basement door, unmute the iPhone Locator Plugin because I may be leaving the house and want it to arm my security system when I move far enough away from my property. Lets say though I open one of the doors to go outside and get something, then just return to the house. Now the iPhone locator app stays “unmuted”/“present” even though I’m still staying home and would like it to remute to save iPhone battery life until I actually truly do leave the house for an extended period of time and want my security system armed. What kind of additional logic could I use with my mute/unmute PLEG plugin to accomplish this? Thanks again for the help. I am totally new to PLEG but the more advice I’m given on it I think the more I’m starting to grasp it and see how powerful it really is.

@agoodman

So I think in looking at what you have, there is actually a mistake in the CPhoneMute section. Having CPhoneMute in that condition, is actually somewhat circular and probably not effectively functioning there. I believe this should be CPhoneUnmute in the CPhoneMute condition. This will effectively re-mute the phone after the set time has passed. In your case, 1 minute. Then what should happen is the Mute condition should mute the phone when it has sensed you home for X minutes. Unmute condition should then unmute the phone when it detects sensors tripped (assuming border doors and such). They will basically toggle back and forth as necessary. For the auto-arming, you can then create a condition where TAlexAway AND TLauraAway will set the alarm etc. The Mute/Unmute will stop evaluating once the Phones are switched to away status, but will kick back in when you arrive home again.

@shmixx

So in order for it to function properly the way I want it to (toggle back and forth as necessary), should I change my logic to 2 separate conditions to remove the “OR” clause to look like what you had instead?:

CPhoneMute1: TAlexHome AND (TAlexHome; Now > 1:00)
CPhoneMute2: TAlexHome AND (CPhoneUnmute; Now > 1:00)

Was the “OR” the issue where it was preventing the logic from toggling back and forth between the two states? I’m just trying to take this all in. Also, how would I add my gf’s phone (“TLauraHome” and “TLauraAway”) into the equation where the mute/unmute PLEG would work for both phones? Just add another condition(s)?

Eventually, as you mentioned I want to create a condition where TAlexAway and TLauraAway will arm the alarm sensors, but ONLY if both of the iPhones are detected in the “away” state by the iPhone Locator Plugin. This way if one of us leaves, but the other is home, the alarm sensors will know not to arm because someone is still present in the house much like an occupancy sensor. Likewise when either one of us returns home I want to iPhone Locator plugin to disarm the alarm sensors (which it actually is already able to do with Vera’s built in scene builder). Yikes! That sounds like some fun? lol :-\ Would I even do that in the same PLEG or should I create another copy of the PLEG plugin to create a totally separate one for the alarm sensor arming/disarming.

@agoodman

Actually I believe the only thing causing the issue in your logic before, was the CPhoneMute being listed instead of CPhoneUnmute:

CPhoneMute TAlexHome AND ((TAlexHome; Now > 1:00) OR (CPhoneMute; Now > 1:00))

Notice that your condition is CPhoneMute and in the condition you specify CPhoneMute. What I believe you meant to insert here, which I believe should work as necessary, is: (CPhoneUnmute; Now > 1:00)

To give you some more background, see the code I originally used for this myself along with my GF phone as well. In my case, I broke out the two sets of conditions into 2 Mute Conditions. You could concatenate them further I would imagine making it less conditions to list, but it gets harder to remember/break down when you come back to it or when troubleshooting. On the away condition, I would arm the house, and the home would disarm. The extra Now > 1:00 clause in the Away scene is to counter flukes in the locator hitting a hiccup and marking both phones as away. It happened a few times before I put that in, and seemed to smooth it out. The hiccups usually correct themselves within a minute.

CONDITIONS Name Expression Last True State CPhoneMuteOn1 (TShawnHome AND (TShawnHome; Now > 5:00)) OR (TTarynHome AND (TTarynHome; Now > 5:00)) 2013-11-24 10:59:25.134 true CPhoneMuteOn2 (TShawnHome AND (CPhoneMuteOff; Now > 5:00)) OR (TTarynHome AND (CPhoneMuteOff; Now > 5:00)) 2013-11-24 11:29:25.139 true CPhoneMuteOff TFrontDoor OR TGarageDoor OR TArmed 2013-11-24 11:23:45.069 false CPhoneAway (TShawnAway AND TTarynAway) AND ((TShawnAway; NOW > 1:00) OR (TTarynAway; NOW > 1:00)) 2013-11-24 10:04:25.144 false CPhoneHome (CPhoneAway;TShawnHome) OR (CPhoneAway;TTarynHome) 2013-11-24 10:53:43.630 true

Lastly, on the note of another PLEG, I would try and confine as many conditions as you can in one PLEG. The less “devices” you create in Vera, the more memory you save. Having a Vera Lite, I’m conscious of how many devices and plugins I have. I’ve since removed the locator plugin myself because it was causing some issues on my Vera. On a fresh build I’ve not installed it, and I’ve faired better. Battery drain also comes into play as a potential issue, so try and save battery as much as possible.

@shmixx

Thanks for the reply again. I see what you mean now with putting in CPhoneUnmute where I had CPhoneMute previously. I don’t know why, but all of a sudden the muting/unmuting PLEG stopped working for me even before I made your change. I opened the back door to get something, went back in, and since then my iPhone hasn’t muted at all automatically. Can you take a look again at my status if you have a minute? It was working fine and then it seemed to stop working for no reason.

[code]
PLEG Mute/Unmute

Device ID: 752014-01-29 18:12:52.538 PLC Version: 5.7

Triggers

Name Description State Last True Last False
TAlexHome ()Alex's iPhone is present true 2014-01-29 18:04:24.264 2014-01-29 18:04:22.806
TAlexAway (
)Alex's iPhone is away false 2014-01-29 18:04:22.807 2014-01-29 18:04:24.264
TLauraHome ()Laura Fornaro?s iPhone is present false 2014-01-29 12:51:48.264 2014-01-29 12:51:55.795
TLauraAway (
)Laura Fornaro?s iPhone is away true 2014-01-29 12:51:55.796 2014-01-29 12:51:48.264
TBasementDoor Basement Door is tripped false 2014-01-29 17:15:24.519 2014-01-29 17:15:29.169
TFrontDoor Front Door is tripped false 2014-01-29 13:07:48.025 2014-01-29 13:08:21.075

Conditions

Name Expression State Last True Last False
CPhoneMuteAlex TAlexHome AND (TAlexHome; Now > 3:00) OR (CPhoneUnMuteAlex; Now > 3:00) true 2014-01-29 18:07:56.865 2014-01-29 17:58:12.460
CPhoneUnmuteAlex TFrontDoor OR TBasementDoor OR TAlexAway false 2014-01-29 18:04:22.822 2014-01-29 18:04:24.268
CPhoneMuteLaura TLauraHome AND (TLauraAway; Now > 3:00) OR (CPhoneUnMuteLaura; Now > 3:00) true 2014-01-29 17:58:12.464 2014-01-29 12:51:55.108
CPhoneUnmuteLaura TFrontDoor OR TBasementDoor OR TLauraAway true 2014-01-29 12:51:55.805 2014-01-29 12:51:48.297
Actions

Actions for Condition: CPhoneMuteAlex

Immediate

Device Action Arguments
(*)Alex's iPhone SetMute newMuteStatus=1

Actions for Condition: CPhoneUnmuteAlex

Immediate

Device Action Arguments
(*)Alex's iPhone SetMute newMuteStatus=0

Actions for Condition: CPhoneMuteLaura

Immediate

Device Action Arguments
(*)Laura Fornaro?s iPhone SetMute newMuteStatus=1
Actions for Condition: CPhoneUnmuteLaura

Immediate

Device Action Arguments
(*)Laura Fornaro?s iPhone SetMute newMuteStatus=0[/code]

I see two things you might need to correct:

CPhoneMuteLaura - you used TLauraAway, I’m guessing you meant TLauraHome.
CPhoneMuteAlex/Laura - I would use the TAlexHome AND on the second half of the OR. I’ve also found that in most cases, it helps to put in the parenthesis, even if the logic should read without it. For this reason I would suggest:

(TAlexHome AND (TAlexHome; Now > 3:00)) OR (TAlexHome AND (CPhoneUnMuteAlex; Now > 3:00))

On both you and Laura mute cases.

One other thought on joining these conditions: If you join the conditions of Laura and Alex, this helps improve efficiency as you work toward the auto-arm auto-disarm situation. It will also help in saving battery life. If you think about the scenario where 1 leaves, and the other is still home, there is no reason to leave the phone that left unmuted. Obviously if you want to put some other automation in there for individuals, lights coming on, changing temperatures for preference of Alex vs Laura, then there is reason to separate them. Additionally, it makes the Unmute clause easier, as all you need to do is add OR TLauraAway to your CPhoneUnmuteAlex condition, and set the action to unmute both phones.

Just some food for thought on optimizing battery life. As I mentioned, you will likely find that there is a cost if not tuned well. A good leveling would be to combine this with the Ping plugin and setting a DHCP reservation of a set IP for both phones. This allows you to get a better auto-disarm in my tests without a hit to battery life.

Oh and one other note - you may have an error because the condition was already satisfied and it might need to cycle through the phone in an away vs home state to truly kick into motion again.

Thanks for catching those two errors. You do make really important points in regards to battery life. If I can get this basic PLEG to work maybe then I can move on to making even finer-tuned changes but one step at a time for me lol. I made the changes so it appear now as below:

[code]

Triggers

Name Description State Last True Last False
TAlexHome ()Alex's iPhone is present true 2014-01-29 20:53:15.701 2014-01-29 20:47:36.823
TAlexAway (
)Alex's iPhone is away false 2014-01-29 20:47:36.824 2014-01-29 20:53:15.702
TLauraHome ()Laura Fornaro?s iPhone is present true 2014-01-29 20:53:12.078 2014-01-29 20:47:53.573
TLauraAway (
)Laura Fornaro?s iPhone is away false 2014-01-29 20:47:53.573 2014-01-29 20:53:12.078
TBasementDoor Basement Door is tripped false 2014-01-29 21:19:27.180 2014-01-29 21:19:32.820
TFrontDoor Front Door is tripped false 2014-01-29 13:07:48.025 2014-01-29 13:08:21.075
Conditions

Name Expression State Last True Last False
CPhoneMuteAlex1 (TAlexHome AND (TAlexHome; Now > 3:00)) OR (TAlexHome AND (CPhoneUnMuteAlex; Now > 3:00)) true 2014-01-29 21:51:00.251 2014-01-29 21:39:20.287
CPhoneUnmuteAlex TFrontDoor OR TBasementDoor OR TAlexAway false 2014-01-29 21:19:27.185 2014-01-29 21:19:32.825
CPhoneMuteLaura (TLauraHome AND (LauraHome; Now > 3:00)) OR (LauraHome AND (CPhoneUnMuteLaura; Now > 3:00)) true 2014-01-29 20:51:28.108 2014-01-29 20:48:28.108
CPhoneUnmuteLaura TFrontDoor OR TBasementDoor OR TLauraAway false 2014-01-29 21:19:27.194 2014-01-29 21:19:32.830
Actions

Actions for Condition: CPhoneUnmuteAlex

Immediate

Device Action Arguments
(*)Alex's iPhone SetMute newMuteStatus=0

Actions for Condition: CPhoneMuteLaura

Immediate

Device Action Arguments
(*)Laura Fornaro?s iPhone SetMute newMuteStatus=1
Actions for Condition: CPhoneUnmuteLaura

Immediate

Device Action Arguments
(*)Laura Fornaro?s iPhone SetMute newMuteStatus=0

Actions for Condition: CPhoneMuteAlex1

Immediate

Device Action Arguments
(*)Alex's iPhone SetMute newMuteStatus=1[/code]

I’m now getting two errors in the Vera status:

PLEG Mute/Unmute[75] : (TLauraHome AND (LauraHome; Now > 3:00)) OR (LauraHome AND (CPhoneUnMuteLaura; Now > 3:00)): Invalid Key token: LAURAHOME

and also: IPhoneLocator : Bad or No device found:{“maxMsgChar”:160,“isMac”:false,“lostTimestamp”:“”,“batteryStatus”:“Unknown”,“activationLocked”:false,“lostDevice”:{“createTimestamp”:1386255811471,“emailUpdates”:true,“userText”:true,“text”:"This iPhone has been lost. Please call me. ext.

I think that last error message is referencing the iPhone Locator plugin directly? Maybe that’s why the muting/unmuting isn’t working right now…