Hi,
I have built a PLEG device to monitor the ping status of two phones. If both phones are not pingable, it triggers the house cameras to arm and lights to turn off. if either phone becomes pingable after the house is armed the house camera should disarm and lights come on.
Here is my PLEG setup:
Triggers
Name Description Last Trigger State
Rich_leaves Rich Ping Armed is Tripped 2013-12-16 22:19:55.309 false
Helen_leaves Helen Ping Armed is Tripped 2013-12-16 22:21:36.142 false
Rich_arrives Rich Ping Armed is not Tripped 2013-12-16 22:20:05.973 true
Helen_arrives Helen Ping Armed is not Tripped 2013-12-16 22:21:36.522 true
Device Properties
Name Device Name Device Variable Last Change Value
Rich_Status Rich Ping Armed Tripped 2013-12-16 22:20:05.982 0
Helen_Status Helen Ping Armed Tripped 2013-12-16 22:21:36.530 0
Day_or_Night Day or Night Status 2013-12-16 22:03:27.342 0
Conditions
Name Expression Last True State
Arm_House (Rich_leaves AND Helen_Status == 1) OR (Helen_leaves AND Rich_Status == 1) 2013-12-16 22:19:55.324 false
Disarm_House_Evening (Helen_arrives AND Arm_House == 1) OR (Rich_arrives AND Arm_House == 1) 2013-12-16 22:20:01.040 false
Actions
Actions for Condition: Disarm_House_Evening
Immediate
Device Action Arguments
Front Door Sensor SetArmed newArmedValue=0
IP Camera Motion Sensor SetArmed newArmedValue=0
Back Door Sensor SetArmed newArmedValue=0
Alarm SetTarget newTargetValue=0
Lounge Lamp Left SetLoadLevelTarget newLoadlevelTarget=60
Actions for Condition: Arm_House
Immediate
Device Action Arguments
Back Door Sensor SetArmed newArmedValue=1
Front Door Sensor SetArmed newArmedValue=1
IP Camera Motion Sensor SetArmed newArmedValue=1
Alarm SetTarget newTargetValue=1
Lounge Lamp Left SetLoadLevelTarget newLoadlevelTarget=0
This is working as expected. I am trying to include a night or day sensor but it doesn’t work as expected and I’m pretty sure its down to the condition expression that I tried.
I tried amending Disarm_House_Evening to:
(Helen_arrives AND Arm_House == 1 AND Day_or_Night == 0) OR (Rich_arrives AND Arm_House == 1 AND Day_or_Night == 0)
I also created an alternative for when its daytime, which disarms the house but doesn’t do anything to the lights.
Can you have 3 x AND within parenthesis as the results are very erratic with what I did?
Many Thanks.
Amended the OP as I have this working but am struggling to incorporate night/day in to it.
Any advice please?
The simple way to use Day or Night in PLEG is as a Trigger. Create one called ItsNight as Day or Night indicates Night. Now you can just add the term And ItsNight to your conditions. You can also use !ItsNight for daytime or create another trigger ItsDay as Day or Night indicates daytime.
You can have many terms within parenthesis. I’m sure there is a limit but it is very large. When you combine conditional expressions with logic terms, it is good to separate them with parentheses. This helps readability and can help to avoid errors of precedence.
E.g. (Helen_arrives AND (Arm_House == 1) AND (Day_or_Night == 0)) OR ((Rich_arrives AND (Arm_House == 1) AND (Day_or_Night == 0))
The state of a logical condition or trigger is true or false. You can therefore just use the name rather than test it for == 1. You can also simplify your condition by removing duplicate terms. So your condition could be:
ItsNight AND Arm_House AND (Helen_arrives OR Rich_arrives)
You will have trouble using pings … because occasionally they will have a false reading.
This is caused by many things … but is quite typical with cell phones.
Assuming Pings work 100% … you can break things down into simpler clauses:
ArmHouse Rich_leaves and Helen_leaves
DisarmHouse Rich_arrives or Helen_arrives
DisarmAtNight DisarmHouse and (DayOrNight == 1)
Assuming Both are home, and the phones do not both have intermittent failures at the same time … this should work. If only one person is home … and you have an intermittent failure … this may cycle to arm/disarm, and at night that may turn some lights on.
I tested RexBecketts idea last night and it arms correctly but it doesn’t disarm even when the ping sensors detect the phones again. It’s almost as if the system isn’t detecting the “untripping”. I will test RichardTSchaefers tonight and report back.
If this doesn’t work I will try and upload logs etc.
Many thanks!
OK, did some more testing. This is displaying very erratic behaviour.
Some times it arms when only one phone becomes unpingable and it doesn’t do anything to the lamp. Other time it works when both phones become unpingable but then only disarms when both become pingable again.
Current config below. Log attached.
Triggers
Name
Description
Last Trigger
State
Rich_leaves Rich Ping Armed is Tripped 2013-12-17 17:27:33.135 true
Helen_leaves Helen Ping Armed is Tripped 2013-12-17 17:32:15.163 true
Rich_arrives Rich Ping Armed is not Tripped 2013-12-17 17:18:33.585 false
Helen_arrives Helen Ping Armed is not Tripped 2013-12-17 17:31:42.413 false
ItsNight Day or Night indicates Night time. 2013-12-17 15:52:18.114 true
ItsDay Day or Night indicates Day time. 2013-12-17 08:03:15.109 false
Device Properties
Name
Device Name
Device Variable
Last Change
Value
Rich_Status Rich Ping Armed Tripped 2013-12-17 17:29:32.106 0
Helen_Status Helen Ping Armed Tripped 2013-12-17 17:33:52.129 0
Conditions
Name
Expression
Last True
State
Arm_House (Rich_leaves AND Helen_Status == 1) OR (Helen_leaves AND Rich_Status == 1) 2013-12-17 17:32:15.182 false
Disarm_House_Evening (ItsNight AND (Helen_arrives OR Rich_arrives)) 2013-12-17 17:31:42.432 false
DIsarm_House_Day (ItsDay AND (Helen_arrives OR Rich_arrives)) 2013-12-17 13:17:15.261 false
Actions
Actions for Condition: Disarm_House_Evening
Immediate
Device
Action
Arguments
Front Door Sensor SetArmed newArmedValue=0
IP Camera Motion Sensor SetArmed newArmedValue=0
Back Door Sensor SetArmed newArmedValue=0
Alarm SetTarget newTargetValue=0
Lounge Lamp Left SetLoadLevelTarget newLoadlevelTarget=60
Actions for Condition: Arm_House
Immediate
Device
Action
Arguments
Back Door Sensor SetArmed newArmedValue=1
Front Door Sensor SetArmed newArmedValue=1
IP Camera Motion Sensor SetArmed newArmedValue=1
Alarm SetTarget newTargetValue=1
Lounge Lamp Left SetLoadLevelTarget newLoadlevelTarget=0
Actions for Condition: DIsarm_House_Day
Immediate
Device
Action
Arguments
Alarm SetTarget newTargetValue=0
Back Door Sensor SetArmed newArmedValue=0
Front Door Sensor SetArmed newArmedValue=0
IP Camera Motion Sensor SetArmed newArmedValue=0