Program Logic (Timer and Event Generator) Beta

The next phase of the Program Logic Plugins is available.
This allows you to use ANY variable in a Vera device in a condition expression … and subsequently to trigger an event. If the variables you select are changed, the condition expressions are evaluated. Condition expressions can now be any combination of Triggers, Schedules, and/or Device Variables

i.e. you can create a trigger when two variables are different from each other by some amount.
Bind UpperTemp to upstairs temp sensor
Bind DownTemp to lower level temp sensor
Condition:
HvacOn = (UpperTemp - LowerTemp > 5.1) and (not (08:00:00; UpperTemp; 16:00:00))

This condition turns on the Hvac if the temperature difference is > 5.1 degrees at night.
This also shows the last change of a Device Variables can be used in a sequence expression.

Or how about a Vera Alert if the Weather station quits working:
Bind OutSideTemp to Weather Plugin outside temp variable.
Condition:
WeatherStationTimeOut = OutSideTemp;NOW > 2:00:00

Events based on temperature and lighting levels are now easily manageable.

Prior to this variables in condition expressions were only binary, true or false.
Now they have values.
The following are the operators (from highest to lowest precedence) you can use in a condition expression:
Numbers:
Unary: -
% Modulo
* /
+ -
> >= < <= == != Numeric Comparison
Strings:
… (Concatenation)
eq ne ge gt lt le String <Lexical Comparison
Boolean:
Unary not !
and
or

[hr]
To install extract all of the files from the attached zip file and download to your Vera … This assumes you have already installed the Plugins from the App store first!
[hr]
Once you see the changes in the UI I will let you guess what the next phase will be ;D

The code has been released so the Beta files have been removed.
See the [url=http://RTS-Services.com/Vera/Plugin/PLEG]http://RTS-Services.com/Vera/Plugin/PLEG[/url] Website for details.

Sound great, just installed and started testing!

An issue I run into is how to specify a match on a string?

I’ve tried the following:

Input is a Device Property, in this case TransportState, it gives the right Current Value, also in the log. Named input ‘KeukenState’

Condition is: TestCond = 5 > 4 and Keukenstate eq PLAYING. This gives an error 'Invalid value token: PLAYING.
The 5 > 4 is there just to check the basic evaluation working.

What is the right way to match a string? I can see from the Lua log that the property is monitored correctly and the values are passed through.

Yep … that’s missing … I added literal numbers … but not litteral strings …
I will add support for ‘XXX’ and “XXXX”.
It will be in PL-Beta3.zip check back later …

you are a rock star.

;D

I just update the files to PL-Beta3.zip
Added support for string literals.
Fixed a bug I introduced in editing triggers.

This does work brilliantly, it saves a lot of coding to make something work!

Here’s my scenario: I have an Hifi amplifier that, due to being a class-a amp, uses a lot of energy even when not playing. I use this amplifier with a Sonos streaming audio device.

Using PLEG I can now monitor the Sonos device state. If it’s playing Audio, I switch on the amplifier. If no audio is playing, I turn of the amplifier. I use one Device Property as input (TransportState). I have to conditions configured:

Amp_On = DP_TransportState eq ‘PLAYING’
Amp_Off = DP_TransportState ne ‘PLAYING’

These two conditions trigger scenes to turn on or off the amplifier.

Now I just want to leave the amplifier on for 10 extra minutes after the audio has stopped, so I changed the last condition to:

Amp_Off = DP_TransportState ne ‘PLAYING’ and (NOW > 10:00)

This however fails on the parsing of the condition with error ‘Invalid Value token: NOW’. I know I can do this in other ways as well though.

Great stuff and a really generic solution to a lot of scenario’s I can imagine. Actually it makes the Combination Switch obsolete to me.

You must use a sequence expression syntax, and is only valid there.

NotPlaying = DP_TransportState ne ‘PLAYING’
Amp_Off = NotPlaying;NOW > 10:00

Note: I have not tested a Condition variable in a sequence expression … but it should work.
Triggers, Schedules, and Condition Variables get a time attached to them when they are first evaluated as true.

Works this way, wow!

This saves me quite a bit of energy I think… More importantly, it was fun getting this to work!

Always looking for someone to add a review:
[url=http://apps.mios.com/write-review.php?id=3066]MiOS Apps

Done! :wink:

The code has been released so the Beta files have been removed. This thread is now locked.

See the Program Logic Event Generator - Vera Plugin Website for details.