PLEG - Basic Concepts

In an effort to get comfortable with PLEG and its nuances, I decided to create a simple scenario and grow from there. But even this test case is stumping me:

Scenario: SwitchA and SwitchB control LightA. So… if either SwitchA or SwitchB are turned ON, then LightA gets turned ON, as well. If either SwitchA or SwitchB gets turned OFF, then LightA gets turned OFF. Similar in operation to a 3-way lighting circuit.

In practice I get unpredictable results, and I believe it has something to do with the Condition not being set up properly. The action will fire the first time I try it, but I need to toggle the triggers back to both ON or both OFF before it will trigger again. What I want to accomplish is a virtual 3-way circuit.

Here is what I have – what is the proper way to code this problem set?

Triggers
Name Description
SwitchA_ON SwitchA is turned on
SwitchA_OFF SwitchA is turned off
SwitchB_OFF SwitchB is turned off
SwitchB_ON SwitchB is turned on

Schedules
Name Type Time Days

Conditions
Name Expression
SwitchON SwitchA_ON or SwitchB_ON
SwitchOFF SwitchA_OFF or SwitchB_OFF

Actions

Actions for Condition: SwitchON
Device Action Arguments
LightA SetLoadLevelTarget newLoadlevelTarget=100

Actions for Condition: SwitchOFF
Device Action Arguments
LightA SetLoadLevelTarget newLoadlevelTarget=0

Any help demystifying the PLEG syntax would be greatly appreciated.

Regards, Mark

You have conflicting logic. I thing you want:

SwitchOFF NOT SwitchOn

or equivalently:

SwitchOff SwitchA_OFF AND SwitchB_OFF

Actions fire ONLY when a condition goes from FALSE to TRUE.

Hi Richard - Thanks for the suggestion. Unfortunately when I changed SwitchOFF to be “NOT SwitchON” the problems did not get corrected. Here is my current Status:

Triggers
Name Description Last Trigger State
SwitchA_ON KitchenSwitchA is turned on July 11, 2013 4:03:36 PM CDT false
SwitchA_OFF KitchenSwitchA is turned off July 11, 2013 4:07:37 PM CDT true
SwitchB_OFF UpperHallSwitchB is turned off July 11, 2013 4:08:07 PM CDT true
SwitchB_ON UpperHallSwitchB is turned on July 11, 2013 4:03:41 PM CDT false

Schedules
Name Type Time Days Last Schedule

Conditions
Name Expression Last True State
SwitchON SwitchA_ON or SwitchB_ON July 11, 2013 4:03:36 PM CDT false
SwitchOFF NOT SwitchON July 11, 2013 10:05:17 AM CDT true

Actions

Actions for Condition: SwitchON
Device Action Arguments
BackHallLightA SetLoadLevelTarget newLoadlevelTarget=100

Actions for Condition: SwitchOFF
Device Action Arguments
BackHallLightA SetLoadLevelTarget newLoadlevelTarget=0

At 4:07:37pm and then at 4:08:07pm, I flipped both switches OFF to see if BackHallLightA would turn OFF, but it did not. When looking at Status Report I see that triggers SwitchA_OFF and SwitchB_OFF are both TRUE, which I would expect, but looking at the Condition for SwitchOFF, the last time it became TRUE was this earlier this morning in some other testing. i.e. - PLEG did not see that the condition SwitchOFF became TRUE @ 4:08:07 when both switches became FALSE.

What am I missing?

Regards, Mark