Program Logic Core
Provides the computation core for the Program Logic Timer Switch and
the Program Logic Event Generator
Features
- Condition Expression Evaluator
- Input Device Property Editor
Any Device Property that you can see in the second half of the Device's Advanced Tab is available.
You name the properties; these names are used in the condition expressions.
- Input Trigger Editor
Any Trigger that you can add to a scene, you can add as an input to this device.
An interactive editor, similar to the scene trigger editor, is provided.
You name the triggers; these names are used in the condition expressions.
- Input Schedule Editor
You can use a named schedule in your Condition Expressions.
You can optionally specify the duration a schedule is considered active; the default is only the time of the scheduled event.
You can optionally specify a random delay for both the start time as well as the off time.
All on and off events for the times have a smart startup. They will maintain their on/off schedules even when a Vera Restart occurs before or during the schedule.
- Action Editor
This is a subset of the Scene Editor (The Devices Tab, and the Advanced Tab). It allows you to associate a set of device commands with a Condition Expression.
It does support delayed actions.
The ability to run a Scene in the Actions. This is only provided in the Advanced tab of the Actions editor ... By Selecting the PLEG/PLTS at the top where it asks to Pick a device. Then select the RunScene option.
- Report and Status.
Report describes the configuration of the PLEG/PLTS device. The Status report is useful for debugging. It has all of the information from the Report plus details of the state and timestamps for all inputs and conditions.
License
When first installed you will have 30 days of unlimited access for 3 PLEG or PLTS devices (total count). After 30 days you will be allowed to use this software without a license with a max of 5 inputs and 5 conditions for these 3 devices.
The purchase of a license will provide you unlimited inputs and conditions for a total of 4 PLEG or PLTS devices (total count). The license is tied to your Vera via it's serial number. The cost for a license is $5.95 US and is a one time fee. If you need more devices you can purchase multiple licenses.
If you change or upgrade your Vera you will need a new license (remember the license is tied to your serial number). The upgrade policy is as follows. If you have N licenses ... we will provide you with N Licenses for the price of N/3 rounded up to the next whole licenses. (i.e. if you had 1 license you will need to buy 1 license. If you have 5 licenses, you will have to buy 2 licenses). After purchasing your new license(s) email us to obtain your additional licenses.
You can purchase your license from the Registration Portal, which is accessible from the Plugin Devices. You can always go back to the Registration portal if you want to obtain an additional license and/or retrieve your license key.
Operation
When are conditions Evaluated ?
The condition Expressions are evaluated whenever an input Trigger is fired, a Device Property is changed, or a Schedule On or Off has arrived. Also if the NOW clause is used then conditions are evaluated every minute.
When will true conditions cause a Trigger and or Action to fire ?
In order for a Condition to initiate an output Trigger and/or fire an Action the following must be true:
- The Condition Must be true, and must have previously not been true. (i.e. the first time it becomes true). This is also the time stamp associated with the condition.
The requirement that it not be previously true is relaxed if the Repeat checkbox is specified for the Condition.
- One of the variables in the Condition Expression must be the reason the conditions are being evaluated.
Also, the PLTS, PLEG (as appropriate) must be Armed for the actions to be executed. Other scenes or plugins can trap the Condition XXX is satisfied independent of the Armed status.
Can I pass parameters to the Actions ?
Yes, using the Advanced tab of the Action Editor you can place a condition Variable, or Expression in the argument of a device action using the following syntax:
{(ConditionOrExpression)}
Inputs
The following editors provide the user the ability to bind any of the following input types to variables that can be used in your Condition Expressions.
- Input Trigger Editor
Any Trigger for Any Device that you can add to a scene, or Device Notification, you can also use as an input to this device.
An interactive editor, similar to the scene trigger editor, is provided.
You name the triggers; these names are used in the condition expressions.
The variables have a Boolean (TRUE or FALSE) value based on their current state.
The sequence time is associated with when the variable last triggered.
- Input Device Property Editor
Any Device Property that you can see in the second half of any Device's Advanced Tab is available.
You name the properties; these names are used in the condition expressions.
The variables have a data type defined by the bound devices property.
The Editor allows you to dynamically see the current state of the device variable. This is important, because often the values you see are transformed by various user interface components. You will need to use the values you see here.
The sequence time is associated with when the variable was last updated.
- Input Schedule Editor
You can use a named schedule in your Condition Expressions.
You can optionally specify the duration a schedule is considered active; the default is only the time of the scheduled event.
You can optionally specify a random delay for both the start time as well as the off time.
All on and off events for the times have a smart startup. They will maintain their on/off schedules even when a Vera Restart occurs before or during the schedule.
In addition to the features of the schedules available to scenes the following are supported:
- Schedules on a specific day of ANY year. Use a year of *
- Off Schedules - provides not just a point in time, but an interval. Relative and Absolute off times are supported.
- Interval times are referenced as HH:MM:SS as opposed to Vera's XX seconds, or XX minutes, or XX Hours.
- Support timers that can be triggered or retriggered from the PLEG/PLTS action StartTimer.
A timer of Self Trigger or Self ReTrigger can only be started from this action.
If a subsequent StartTimer is already sent to a timer that is active, it is ignored, unless it is of type Self ReTrigger in which case its timer is restarted.
Condition Expression Syntax
All conditions are named. For PLTS all of the conditions are predefined. For PLEG there are two RESERVED condition names. These are ARM and BYPASS. These allow you to add logic to ARM and BYPASS respectively the current PLEG/PLTS device.
A condition is satisfied when the condition expression is true. A condition expression can be any of the following:
Grouping Expressions using parentheses
( expression )
This is necessary to explicitly control the evaluation logic, otherwise evaluation is decided by the precedence of the operators.
The simplest expression ...
Just a Device Property, Schedule, or Trigger, or Condition Name
- DevicePropertyN
- TriggerN
- ScheduleN
- ConditionN
Counter Expressions
Actually this is just a simplification of the general expression described below.
TriggerOrCondition1 + TriggerOrCondition2 + ... TriggerOrConditionN > 2
TriggerOrCondition1 + TriggerOrCondition2 + ... TriggerOrConditionN < 2
Each currently active trigger or condition counts as 1.
This expression is true when the count is greater or less than, as appropriate, to the count of triggers or conditions.
Sequence Expressions
Every Trigger, Schedule, or Condition variable has a time associated with it when it was most recently transitioned from false to true. Note: If a condition is specified as Repeat then the time is set every time the condition is evaluated to true. A device property has a time when it was last changed. This time is what is used when you reference these variables in a Sequence Expressions.
A SequenceToken in a Sequence expression can be any of the following:
- TriggerN or !TriggerN
- ScheduleN or !ScheduleN
- ConditionN or !ConditionN
- Device Property
- Absolute Time in HH:MM:SS format
- NOW - A reserved word representing the current time.
This is useful for timeouts: (DoorOpen; Now > 30:00) Trigger if DoorOpen is still valid after 30 minutes.
The ! variants use the Off Time Stamp, otherwise, the On TimeStamp is used.
These can be specified to be either a time ordered, or time unordered sequences of tokens.
- To specify a list of Triggers, Schedules, Device Properties, or Conditions that occur in any order, separated then by a comma:
SequenceToken1, SequenceToken2, ... , SequenceTokenN
This is not really meaningful without the following time constraints.
- To specify Triggers, Schedules, Device Properties, or Conditions that must occur in the specified order, separated them by a semi-colon:
SequenceToken1; SequenceToken2; ... ; SequenceTokenN
Followed by one or both of the following time constraints
- > hh:mm:ss
The difference in time between the oldest event, schedule, condition and the newest event, schedule, condition is more than the interval specified
- < hh:mm:ss
The difference in time between the oldest event, schedule, condition to the newest event, schedule, condition is less than the interval specified
i.e. SequenceToken1; SequenceToken2 > 30 < 5:00
This expression is true when SequenceToken2 follows SequenceToken1 by more than 30 seconds but less than 5 minutes.
NOTE: This does not have support for >= or <= comparison operators.
Multiple Trigger Expressions
The syntax is:
TiggerNameOrDevicePropertyOrCondition @ Count
Followed by one or both of the following time constraints
- > hh:mm:ss
The difference in time between the oldest event and the newest event is more than the interval specified
- < hh:mm:ss
The difference in time between the oldest event to the newest event is less than the interval specified
i.e. TriggerOrDevicePropertyOrCondition1 @ 3 < 30
True if TriggerOrDevicePropertyOrCondition1 happens 3 times in less than 30 seconds
This is useful for debouncing noisy triggers. It also allows you to add semantics to how often an event happens.
General Expressions
Note that the leading number for each of the following expressions indicates the precedence of the operator. You can use parenthesis to change the precedence.
- Expressions with String Values
The following operators are supported from lowest to highest precedence (precedence level indicated).
- 4 - eq ne gt ge lt le =~
The =~ operator is a substring match operator. The left hand string is the string to search. The right hand string is the string to search for. This is a case sensitive search. A search string wrapped with forward slaches of the following format: "/SomePattern/" interprets "SomePattern" as an LUA regular expression like match.
- 5 - .. (concatenation operator)
- Expressions with Number Values
The following operators are supported from lowest to highest precedence (precedence level indicated).
- 4 - == != > >= < <=
- 6 - + -
- 7 - * /
- 8 - % (modulo operator)
- 9 - - (unary negation)
- 10 - # #! Return the On or Off Timestamp Respectively
- Expressions with Boolean Values
The following operators are supported from lowest to highest precedence (precedence level indicated).
- 2 - or
- 3 - and
- 9 - not ! (unary negation operators)
- Condition Expressions (precedence level indicated).
- 1 - XX ? YY : ZZ
Which is interpreted as if XX then YY else ZZ
The XX expression must evaluate to true or false. If XX is true then YY is returned. If XX is false, ZZ becomes the result. This expression has the lowest precedence of any operators, use parenthesis to explicitly control the order of evaluation.
- Literals
- String Literals "A String" or 'A String'
- Number Literals 23 or 123
- Time Literals HH:MM:SS - On the Left Side of A Sequence Expression, this is an absolute time during the current day, on the right side it is a relative time.
- NOW - represents the current absolute time, and can be used on the Left side of a Sequence Expression.
If you wish to combine a Sequence and/or Multiple Trigger expression together in a General Expression they MUST be wrapped in parentheses.
In some cases data types can be coerced. A Numeric value of > 0 in a Boolean context is treated as a true. A value of 0 is treated as false. A String of length > 0 in a Boolean context is treated as true. A String of length 0 in a Boolean context is treated as a false. In a Numeric context, a true Boolean has a value of 1 and a false Boolean has a value of 0. In actuality a counted expression is just a numeric addition where the arguments are coerced to zeros or ones before adding the values.
Actions
Each Condition can have a set of actions that can be invoked when the condition is first evaluated to be true, or if the condition is marked as Repeat, then every time it is evaluated to be true.
The action editor looks like the Scene editor, although it has a few less options. It does not allow you to specify Triggers.
You can have LUA code run as part of your actions.
This has the same behavior as a SCENE Level LUA ... i.e. if it returns false, it stops executing the explicit actions. If it returns nothing or true it will run the explicit actions. The LUA has context (unlike a scene).
For each input Variable name or Condition name xxx you have access to it from LUA as
XXX.state
XXX.seq
XXX.oseq
XXX.seqh
Where XXX is the uppercase of the input or condion name. And XXX.state is the value, XXX.seq is the On timestamp and XXX.oseq is the Off timestamp, and XXX.seqh is a history of the last N on timestamps (max of 10, not saved across restarts, only the most recent one is) XXX.seq should always equal XXX.seqh[1]. The seqh is currently only used internally for the Multi-Trigger checks.
The LUA context is unique for each Plugin. You can share global variables between Actions, but not between PLEG/PLTS devices or Vera Scenes.
In a scene, if it has delayed actions, and Vera restarts during the scene, the delayed actions will never happen. In PLEG/PLTS these actions will be invoked even if Vera restarts during the execution of these actions.
In the advanced TAB you can add actions that are not available via the Device Panel. These actions typically require addition input, which cannot be specified on the Devices panel. The PLEG/PLTS device supports the following actions which you may find useful:
- RunScnene - To Run a Scene as part of the actions
- StartTimer - To Start a Timer for the corresponding PLEG/PLTS device.
The StartTimer can optionally, if specifided, override the Interval Off Time of the specified timer.
It's not uncommon to add a Notification using Vera Alerts or the PushNotification in the Advanced Tab for a particular Action to record that a condition has been satisfied.
Usage
If you have an interesting usage you would like to share it please send me a copy of the PLEG/PLTS report and a short description of what it does. I will enumerate and link them here.
Issues
- The ordered sequence only looks at the most recent event time. So the sequence A;B;A will ALWAYS fail.
- String constants with punctuation can cause the problems for the statement analyzer.
Requests
- Ability to copy/paste trigger templates.
- Function Capability
Contact me at Schaefer@RTS-Services.com
|
© Copyright 2017, RTS Services Inc. All Rights Reserved 1675 Hickory Creek Rd Marble Falls, Tx 78654 |