Program Logic Plugins Version 5.3 is Available

To run a scene as part of an action see:
http://forum.micasaverde.com/index.php/topic,14447.msg110455.html#msg110455

Hi Richard,
Thank you… Did not see those instructions before.

Does the Pin code Input set a specific state, or is it just a one time trigger?

The reason I ask is that I am seeing that the Pin code is constantly evaluating true in the condition. So, when create a Condition and evaluate it against a Device Property which is a variable container and later trigger an Away scene which overwrites the variables, the initial condition logic evaluates pin to be true and reverses my scene back to a Home state.

If you have a condition that is invoked from a pin code … then it will only go false when a different pin code is entered.

To get around this I added the ability for conditions whose name start with an underscore .i.e. _AlwaysFire to fire each time the condition is evaluated to be true … not just when it goes from off to on.

Try renaming the condition and see if that does not solve your problem.

Thanks Richard.
Although I renamed it, the problem with my logic remains. The pin status is evaluated against a variable that I set if someone is home. If I set a scene of “away” that clears the “home” binary variable that I create , the sticky true state of the last pin used gets evaluated again against the cleared “home” variable and triggers the action as if I am using my pin again.

I may have to think about a work around. Basically I need the True state of my last used pin to clear soon after it is used with whatever action is triggered or PLEG just triggers on the False->True transition a single time.

I may have to constrain it with timing, find where I can reset the state, or maybe have the pin set a virtual switch.

Any other ideas are much appreciated.

Rename the condition to put an underscore as the first character.
That will cause PLEG to fire the actions each time the condition is evaluated to be true … not just when the condition first becomes true.

So Change the condition name from: Home to _Home

Send me your Status command results so I can see what you are trying to do.

[quote=“RichardTSchaefer, post:25, topic:175016”]Rename the condition to put an underscore as the first character.
That will cause PLEG to fire the actions each time the condition is evaluated to be true … not just when the condition first becomes true.

So Change the condition name from: Home to _Home

Send me your Status command results so I can see what you are trying to do.[/quote]

Hi Richard. Finally coming back to this. I actually want the trigger to ONLY fire a single time when the code is entered in the door. This way, if the HomeStatus variable is set to 0 when I leave, it does not trigger again because the last pin code is still evaluated to be true. I spent a bit of time tonight testing using the underscores and other options to make it work reliably, but failed. Can I constrain the timing of the condition so it is only evaluated for a couple of minutes once the door pin is entered, or do you have a more elegant way?

Triggers
Name Description Last Trigger State
MyPin PIN Code #2 is entered on Front Door Lock 2013-08-27 22:04:43.660 true

Schedules
Name Type Time Days Last Schedule
WakeTime Weekly 06:00:00 1,2,3,4,5,6,7 2013-08-27 06:00:00.101
WorkStart Weekly 07:40:00 1,2,3,4,5 2013-08-27 07:40:00.101

Device Properties
Name Device Name Device Variable Last Change Value
HomeStatus SystemsStatus1 Variable2 2013-08-27 08:12:47.429 1
Sleeping SystemsStatus1 Variable3 2013-08-27 08:12:47.483 0

Conditions
Name Expression Last True State
WakeUp HomeStatus==1 and Sleeping==1 and (WakeTime; Now< 2:00) 2013-08-26 06:00:37.103 false
TimeToWork HomeStatus==1 and WorkStart 2013-08-26 07:40:00.105 false
IamHome MyPin and HomeStatus==0 0 false

Actions
Actions for Condition: IamHome
Device Action Arguments
Office Lamp ToggleState

@niharmehta
The following is only valid for 2 minute when the PIN is entered:

 PIN and (PIN, NOW < 2:00)

Hello Richard (and others),

Once again, well done for your continuous great work ! Your PL is really saving me a lot of Devices and Scenes…

I have 3 questions…

1/ Is there currently a way to set a condition to be ignored for a specified time after it becomes true (and obviously false and true again) ?

If I set for example :
Cond1=(a>b) and C
Cond1 will become true all the time the logic is satisfied, but if become false again, I would like it not to trigger (if logic is satisfied again) for a certain time…

The purpose of this is to ‘debounce’ multiple actions when the conditions are based on sensors that can vary and oscillate around the triggering value. I added an hysteresis, like “Cond1=temp>15” and “notCond1=temp<14”, but when temp oscillates around 15, it just triggers Cond1, then notCond1, Cond1 again, etc… I cannot increase the hysteresis too much, as it will not behave like I want.
As a result, my PLEG is sometimes starting and stopping my home fan system 5 times an hour…

=>so I would like to say : “Cond1=temp>15, and don’t trigger for 10 minutes”

Is it possible with the existing syntax ? If not, would it be possible to add the feature ?

I know I could start a PLTS to do the job, but I will then need many if them…

2/ Other question :
Is it possible to add a condition as input for another one ? Like : “Cond1=a+b” “Cond2=Cond1;c<1:00”

3/ Last question :
What do I need to backup to ‘save’ my PLEG ? If I save somewhere ‘ConditionMap’, ‘ObjectStatusMap’ and ‘Actions’ content, will it be sufficient ?

@Theduck38

  1. Use Multi Trigger Expression and Conditional Expression
    Cond1 = (Cond1 @ 2 > 1:00) ? (temp>15) : Cond1

    This will set the new value if it changed more than 1 minute from previous time otherwise retains current value

  2. Yes condition variables can be used like input variables to other (or the same as above) conditions.

  3. You will also need Prorties, Schedules, and Triggers. (Prior to 5.0 this will not save eveything … Input triggers were stored in a hidden scene.)

[quote=“RichardTSchaefer, post:29, topic:175016”]@Theduck38

  1. Use Multi Trigger Expression and Conditional Expression
    Cond1 = (Cond1 @ 2 > 1:00) ? (temp>15) : Cond1
    This will set the new value if it changed more than 1 minute from previous time otherwise retains current value[/quote]
    Hello Richard, Thanks for your answers.

It seems this syntax never triggers when initial state is ‘False’… no way to get two times a ‘true’ state for Cond1… so PLEG seems to repeat false state at each evaluation.
Other way to say it : I had the equivalent to ‘temp>15’ and cond1 did not become true… I suppose the timestamp of the condition change is set at the end of evaluation ?

To work, it would request for Cond1 to be evaluated with only (temp>15) and re-use the time it happens for the ‘if’ evaluation before the action is sent…

Would : Cond1 = not (Cond1 @ 2 < 1:00) and (temp>15) work ? Or will it work only for the third triggering of cond1 ?

Edit : … or Cond1 = (Cond1;NOW > 1:00) and (temp>15) → can this work if Cond1 has been false in between (will PL take the last ‘true timestamp’ of Cond1 when evaluating ?) ?

Oops you are right.

Cond1 = (temp @ 2 > 1:00) ? (temp>15) : Cond1

Sequence expressions (or multi triggers expressions) get a timestamp for boolean values every time they change from False to True. Device Properties get a timestamp every time they change.

Feature Request…

Is it possible to Arm and DisArm Conditions with a radio button.

Presently, you can Arm/Disarm the entire PLEG, but not Conditions.

I have a PLEG that controls my lighting, some Conditions don’t work properly(yet).
I would like to use the PLEG while I test some conditions and be able to turn off certain conditions that do not function as intended.

[quote=“RichardTSchaefer, post:31, topic:175016”]Oops you are right.

Cond1 = (temp @ 2 > 1:00) ? (temp>15) : Cond1

Sequence expressions (or multi triggers expressions) get a timestamp for boolean values every time they change from False to True. Device Properties get a timestamp every time they change.[/quote]
Speaking of features requests… ;D would it be possible to implement something to ‘debounce’ multiple actions before they are sent ?

Is there a max on the amount of triggers, conditons and/or actions? I have now:
triggers: 20
conditions: 40

On Vera everything is limited by available memory. In general there are no hard coded limits.

But if the number of Conditions gets above 20 … you might have to much complexity in one PLEG
and for maintenance you might want to break it down into manageable chunks.

If you have that much inter-acting logic keep it in the same PLEG.

My comment is that if you Mix a lot of stuff in one … it becomes difficult to maintain.

I have not faced any issues yet, but i have put all my triggers into pleg now and have duplicated them, one for Prowl and one for Twilio, when I have no Internet on my Smartphone.

@Crismaison

Is there a way of getting notifications on a phone without internet ? Currently i use prowl on my iphone, but i think that needs internet. Never looked into Twilio, does that work without internet ?

Yes, Twilio sends a SMS or Calls your phone and reads the message. There is a cost involved, but the first 20 or 30 dollars are for free. SMS costs 10 cents. Used it on my holiday, it worked fine

I have noticed something annoying. It happens every time i add a schedule, or change/add a trigger. It screws up my conditions. I created a schedule WD2 in this example. This has now changed conditions BedroonHot1 to BedroomHoWD2. This obviosly gives errors when i save, which i then have to manaully corect, and change all the BedroomHoWD2 back to BedroonHot1. The weird thing is, it only screws up BedroonHot1, and it always end up BedroomHo*, where * is the new trigger or new schedule. In this case it has also screwed up BedroomVeryHot1 to BedroomVeryHoWD2. Not sure if that condition has been affected before
I just noticed in this case other conditions which were calles *WD have been renamed too to *WD2

HVAC
Device ID: 2502013-09-08 16:10:15.733 PLC Version: 5.1
Triggers
Name Description Last Trigger State
OutsideHot Temperature outside temperature goes above 19 degrees 2013-09-08 14:09:00.288 false
AC_Auto_ON MultiSwitch Switch 3 is turned on 2013-09-05 20:34:48.718 true
LWindowOpen Window Right is tripped 2013-09-07 23:53:19.315 false
RWindowOpen Window Left is tripped 2013-09-07 23:53:25.685 false
HeatingON MultiSwitch Switch 4 is turned on 2013-08-26 17:55:41.858 false
HotWaterON MultiSwitch Switch 5 is turned on 2013-08-26 17:55:43.614 true
Away MultiSwitch Switch 7 is turned on 0 false
Vacation MultiSwitch Switch 8 is turned on 0 false
ACisON Air Condition is set to cool 2013-09-07 22:00:01.322 false
BedroomHot1 Temperature Master Bedroom temperature goes above 23 degrees 2013-09-07 22:09:15.047 false
BedroomVeryhot1 Temperature Master Bedroom temperature goes above 26 degrees 2013-09-05 20:30:17.819 false
BedroomCold1 Temperature Master Bedroom temperature goes below 21 degrees 2013-09-08 09:36:18.087 false
Schedules
Name Type Time Days Random On Delay Off After Type OA Time OA Days Random Off Delay State Last Schedule
WeekdayOn1 Weekly 21:30:00 1,2,3,4,5 None None None false 2013-09-06 21:30:00.104
WeekdayOff1 Weekly 04:50:00 1,2,3,4,5 None None None false 2013-09-06 04:50:00.035
WeekendOn1 Weekly 22:00:00 6,7 None None None false 2013-09-07 22:00:00.053
WeekendOff1 Weekly 07:20:00 6,7 None None None false 2013-09-08 07:20:00.100
check_Window Weekly 21:20:00 1,2,3,4,5,6,7 None None None false 2013-09-07 21:20:00.052
HWOnWD1 Weekly 04:45:00 1,2,3,4,5 None None None false 2013-09-06 04:45:00.100
HWOffWD1 Weekly 05:35:00 1,2,3,4,5 None None None false 2013-09-06 05:35:00.100
HWOnWE1 Weekly 05:50:00 6,7 None None None false 2013-09-08 05:50:00.056
HWOffWE1 Weekly 06:40:00 6,7 None None None false 2013-09-08 06:40:00.057
HWOn1 Weekly 16:30:00 1,2,3,4,5,6,7 None None None false 2013-09-07 16:30:00.061
HWOff1 Weekly 16:50:00 1,2,3,4,5,6,7 None None None false 2013-09-07 16:50:00.050
HeatWDOn Weekly 04:45:00 1,2,3,4,5 None None None false 2013-09-06 04:45:00.195
HeatWDOff Weekly 22:20:00 1,2,3,4,5 None None None false 2013-09-06 22:20:00.100
HeatWEOn Weekly 06:30:00 6,7 None None None false 2013-09-08 06:30:00.060
HeatWEOff Weekly 22:55:00 6,7 None None None false 2013-09-07 22:55:00.100
WD1 Weekly 21:30:00 1,2,3,4,5 None Weekly 04:50:00 1,2,3,4,5 None true 2013-09-06 21:30:00.166
WE1 Weekly 22:00:00 6,7 None Weekly 07:10:00 6,7 None false 2013-09-07 22:00:00.162
WD2 Unknown None Weekly 07:20:00 6 None false 0
Device Properties
Name Device Name Device Variable Last Change Value
DOW DOW 2013-09-08 00:00:00.101 1
WE Weekend 2013-09-07 00:00:00.192 1
Conditions
Name Expression Last True State
OpenWindow BedroomHoWD2 and AC_Auto_ON and (((WeekdayOff1; WeekdayOn1) and WE==0) or ((WeekendOff1; WeekendOn1) and WE==1)) and (NOT OutsideHot) and check_Window and NOT WindowOpen and NOT Vacation and NOT Away 0 null
CloseWindow BedroomHoWD2 and AC_Auto_ON and WindowOpen and check_Window and OutsideHot and NOT Vacation and NOT Away 2013-09-05 21:20:00.045 null
WindowOpen LWindowOpen or RWindowOpen 2013-09-07 23:53:19.329 false
ACmanualHigh BedroomVeryHoWD2 and (21:42:00;NOW) and NOT Vacation and NOT Away 0 null
AC_On BedroomHoWD2 and AC_Auto_ON and (((WeekdayOff1; WeekdayOn1) and WE==0) or ((WeekendOff1; WeekendOn1) and WE==1)) and NOT WindowOpen 2013-09-07 22:00:00.083 null
AC_Off (BedroomCold1 and (AC_On; Now > 15:00)) or ((WeekdayOn1; WeekdayOff1) and (WeekendOn1; WeekendOff1)) or (NOT AC_Auto_ON) 2013-09-08 00:34:51.093 false
AC_Off2 WindowOpen and ACisON 2013-09-01 00:41:42.774 false
HWOn (HWOnWD21 or HWOnWE1 or HWOn1) and HotWaterON 2013-09-08 05:50:00.091 null
HWOff (HWOffWD21 or HWOffWE1 or HWOff1) or (NOT HotWaterON) 2013-09-08 06:40:00.092 null
HeatON ((HeatWD2Off; HeatWD2On) or (HeatWEOff; HeatWEOn)) and HeatingON and (NOT Away) 2013-09-01 06:30:00.145 null
HeatOff ((HeatWD2On; HeatWD2Off) and (HeatWEOn; HeatWEOff)) or (NOT HeatingON) or Away 2013-09-05 22:20:00.079 null
AC_ON_test1 BedroomHoWD2 and AC_Auto_ON and ((WD21 and WE==0) or (WE1 and WE==1)) and NOT WindowOpen 2013-09-07 22:00:00.213 null
AC_ON_test2 BedroomHoWD2 and AC_Auto_ON and (WD21 or WE1) and NOT WindowOpen 2013-09-07 19:12:10.700 null
AC_OFF_test (BedroomCold1 and (AC_On; Now > 15:00)) or (NOT WD21 and NOT WE1) or NOT AC_Auto_ON 2013-09-08 00:34:51.133 null
Actions
Actions for Condition: ACmanualHigh
Immediate
Device Action Arguments
Push Notification SendProwlNotification Event=Turn On AC High Description=Bedroom very hot Priority=1 URL=
HVAC RunScene SceneNameOrNumber=64
Actions for Condition: AC_On
Immediate
Device Action Arguments
Air Condition SetModeTarget NewModeTarget=CoolOn
Push Notification SendProwlNotification Event=AC Description=AC is ON Priority=1 URL=
Actions for Condition: HWOn
Immediate
Device Action Arguments
Test Multi Switch SetStatus1 newStatus1=1
Hot Water SetModeTarget NewModeTarget=HeatOn
Actions for Condition: HWOff
Immediate
Device Action Arguments
Test Multi Switch SetStatus1 newStatus1=0
Hot Water SetModeTarget NewModeTarget=Off
Actions for Condition: CloseWindow
Immediate
Device Action Arguments
Push Notification SendProwlNotification Event=test Description=close window Priority= URL=
HVAC RunScene SceneNameOrNumber=71
Actions for Condition: HeatON
Immediate
Device Action Arguments
Test Multi Switch SetStatus2 newStatus2=1
HVAC RunScene SceneNameOrNumber=74
Actions for Condition: HeatOff
Immediate
Device Action Arguments
Test Multi Switch SetStatus2 newStatus2=0
HVAC RunScene SceneNameOrNumber=73
Actions for Condition: AC_Off2
Immediate
Device Action Arguments
Air Condition SetModeTarget NewModeTarget=Off
Actions for Condition: AC_Off
Immediate
Device Action Arguments
Air Condition SetModeTarget NewModeTarget=Off
Actions for Condition: OpenWindow
Immediate
Device Action Arguments
Push Notification SendProwlNotification Event=Open Bedroom Description=Window Priority=1 URL=
HVAC RunScene SceneNameOrNumber=59