PLEG for heat control

I know others are using PLEG to control their thermostat and I’m looking to do so as well. I’ve been messing with it for a while now and am looking for the best way to do this. Basically I would like to have a base heat up and heat down group of schedule, condition and actions. Then be able to create events that override these base groups. The idea would be that my base heat schedule is static but to create a simple override for one day every week for a month would be much easier if I didn’t have to rewrite the whole condition statement.

The only way I can think to do this reliably is to create a schedule with start and stop for these base groups and then create my special events with start stop times. I’m thinking this would create the system to send commands to the thermostat all of the time which is not ideal.

Perhaps I’m complicating it more than to just do it with an advanced condition and I’m open to that reality if it is true, I just figured it would see if others had a better ideas.


I think you need to add a lot more details to the specifications to get some ideas.
What type of heating system do you have ?
How many zones ? Do you have thermostats ? or are you using Temperature Sensors ?
What do you consider a “Base” schedule to look like ?
What type of overrides are you looking for ? Temperature ? Time of Coverage ?

Ok, certainly, you are right… Sometimes I under post as I’m afraid people will ignore detailed posts as I know you all are very busy!

Heating system is fairly simple. I have three zones, basement, first and second floor. For now I only have first and second floor zwave tstats. Heat only hydronic boiler. I’m in New England so ac is limited to window units for me for the two days of summer heat a year :wink:

The base schedule I am thinking of is say, first floor heat to 68 at 15:45, 62 at 21:45 M-F. Saturday 8:00 68, 22:00 62. Second floor I would have a morning schedule to warm for getting ready and then off to leave and then up at 15:45 and down at 21:45 like first floor. I am leaning towards separate PLEG instances for each tstat because I could bypass them individually but that isn’t a requirement.

I occasionally have band practices or other events that last a set Monday 6-9 or something like that. Being able to just add those without modifying the base conditions,triggers, actions would be great.

Also, I forgot to mention in my first post, I have a scene for something like leave and arm that locks my doors, turns off certain lights, closes garage blah blah and would be nice to have it turn the heat down. That part is easy I think but what would be nice is to have it turn the heat back up when I return. Problem I see there is what if I return after the trigger that turns the heat down every night… I wouldn’t want it to kick back on at 1 am or something.

For the short term I have PLEG just sending me push messages instead of changing the heat to be safe until I work the bugs out of my coding…

Oh, side note, maybe a bug? When adding an action, I click advanced and try to add my push notification, unless I add something else first, it won’t add anything from the advanced tab, if I add something random first, I can add the push and then delete the random item no problem. I did upgrade today but honestly didn’t try again after the update so maybe this is already fixed.

Thanks again for the great plugin!

So it sounds like you want:

  1. Set to cooler temp every night (no overrides)
  2. Set to warmer temp ever afternoon, If you are home, or when you get home.
  3. For one have a morning Warm up morning schedule, If you are home.
  4. If I leave … set to cooler temp.

Sounds like you need a Virtual Switch to control your override …
Have it set on/off by schedule above. With the ability to manual override it.
So the schedule changes the Virtual Switch.
The Virtual Switch setting changes the Setpoints from warmer/cooler as appropriate.

I would add another schedule to turn the Virtual Switch off at 1:00 AM in case you hit the override and decide to stay up some night (working on Vera :slight_smile: )

You did not say what type of thermostats you have … are these battery powered Z-Wave Thermostatic valves ? or 24v Zone valves with a standard wall mounted Z-Wave thermostat ?

I ask because of the comment:

I'm thinking this would create the system to send commands to the thermostat all of the time which is not ideal.

I have Honeywell zwave wall mounted thermostats. They run off of the 24v transformer on my boiler.

I think I was misunderstanding how PLEG handles schedule start stop triggers or perhaps I still am. I was thinking that it worked more like the now command and would be evaluated once a minute. After more reading I think I understand that instead it triggers at the on time and then again at the off time? I didn’t want the system sending zwave commands every minute (or more often) to my thermostat.

Also, I want to avoid setting the heat up and then seconds or minutes later setting it back down. This would put undue stress on my zone valves, burner and direct vent not to mention the start-up wastes of the burner.

Part of my struggle is I am very familiar with and somewhat less C coding. I’m still trying to wrap my brain around the syntax for PLEG. For example, I couldn’t figure out how to do a condition of either T1 or T2 but not T3. perhaps this can’t be done? Anyway I used NOT or ! it highlighted them as unknown variables and LUA barfed on refresh.

I think the virtual switch is a plugin? I will do some looking at that a little later.

Thanks for your reply.

For example, I couldn't figure out how to do a condition of either T1 or T2 but not T3. perhaps this can't be done? Anyway I used NOT or ! it highlighted them as unknown variables and LUA barfed on refresh.

PLEG and LUA syntax are different. LUA does not know about ! operator.
For PLEG NOT and ! are the same.
With PLEG you can do:
T1 and T2 and (! T3)
T1 and T2 and (not T3)
T1 and T2 and not T3

My built in editor does not recognize the unary operators (! and not) you can ignore the warning feedback.

Heh, I missed the “and” so:

(T1 or T2) and not T3

would fire if either t1 or t2 are true but not if t3?

What is the value of adding the parenthesis for (not T3) just another way to do it?

I pulled down the virtual switch plugin. I’ll give it a look but your method makes solid sense.


It has to do with precedence of operators … if you do not remember/know the precedence than it
overrides them. For me it’s a lower cognitive load to read with parenthesis … because I do not have to think about precedence.

In your example:

If you left out the parenthesis than the following two would be the same and not equal to the one above:

Ok, I’m making some progress. Two questions though:

Is it possible to do an absolute time comparison in a condition. For example:
t1 and (21:00:00 > now > 15:00:00) - basically, if trigger 1 and if now is between 3 and 9 pm.

Also, I know it supports passing variables to the action but I’m not sure how to use this function. I was thinking of using the text fields in the virtual switch to hold my high and low set point. That way if I wanted to change them I could do so without walking through several actions to ensure everything is set right. It would also allow me to set both set points to say 58 for a vacation. That way I wouldn’t have to bypass the pleg instance allowing it to continue to send alerts and other things the pleg might be doing.

I’m guessing I would need a device properties input defined with a condition off of that to pass to the action. So my guess is something like:

device property
name: t1
device name=(vswitch)
device variable= text1

condition of
name= c1
condition expression = t1

action of
thermostat device setcurrentsetpoint {(c1)}

Is it possible to do an absolute time comparison in a condition.

That’s what sequence expressions are for:

t1 and (15:00:00; t1; 21:00:00)

Ok, I don’t really understand the syntax but will play with it when I get a few minutes. I Thought that would require all of those to evaluate true in that order.

Any suggestions on the variables? I did a bunch of playing with it and couldn’t get the action to recognize a variable.

You need to review the documentation:

Inputs - Bound to external Triggers, Device Variables, Schdules. All inputs have a name. When the inputs change … The conditions are evaluated.

Conditions - Each condition has a name. They also have an Expression composed of Input Names and other Condition Names.

Actions - Things to do when a condition evaluates to True (Similar to a Scene)

I assure you I have read all of your documentation, much of it several times prior to my first post even. I am not a spoon feed person. I have spent hours trying different things between each posts. I also am not a coder really and what coding experience I have is vb which really isn’t anything like this.

I don’t mean to be insulting as you do what you do of the goodness of your heart and I for one of many appreciate it, but your documentation in many cases is vague and examples are few with little explanation of the ones that are there.

The variables section is one sentence. It says yes you can do it and the syntax is {(conditionorexpression)}. I may be the only one but I have no clue what that means. I know what a condition is in pleg and I know what an expression is but neither of those represent a variable that I’m aware of. In a previous post I put my guess as to what this means hoping you could set me straight as all of my testing around my guess yielded poor results. Are you suggesting that the only variables that can be passed are the names of the triggers and variables or some calculated expression there of?

Please don’t take any offense from my message, I really am trying to learn. If I wasn’t then I wouldn’t have bought this stuff in the fist place, I’d be sitting on my porch guzzling cheap beer and cursing at passing cars like my neighbors :slight_smile:

From my documentation:

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:

If you have not opened up the actions editor … this will not make any sense.

Once you get to this point (the equivalent of a Scene editor).
Add an action like setting a dimmer to 50 percent.

When you go to the advanced tab you will see an action for the specified device with a newLoadlevelTarget action with a value of 50.

You can replace the value of 50 with: {((10 + 10 + 5) * 2)}
This is an example of an expression for an argument for an action.
Of course it is simpler to just write 50 … But you could also use {(SomeOtherDimVal)}

Where you bind the input variable SomeOtherDimVal to a different Dimmer Target property.

Then when you execute this action it will set the specified dimmer value to the same value as the device associated with SomeOtherDimVal
I have done programming since 1971 … so this stuff is trivial to me … but if you asked me to read a page of sheet music I would be totally lost.

I wrote and documented this stuff assuming the reader had some basic knowledge of programming and could apply those skills here. Without some previous basic training … I am sure this all reads like randomly generated text or coded messages for the secret PLEG society.

Perfect. That is exactly what I needed and my variables are working.

One thing I had wrong which is definitely my fault. I thought condition names and input variables we two separate balls of wax. Well, I had a condition with the same name as an input variable. It was different capitalization but that didn’t matter. My action was putting the literal {(Variablename)} just like that as in no substitution into my push messages. I changed the condition name to something else and bang it started working. Same names is a big no no, I should have known better, shame on me.

One more question. I’m using the text1 and text2 variables in the virtual switch. You (can) set these by the advanced editor for the switch. This doesn’t cause PLEG to realize the change and shows it was never updated. I had to write a temp scene that would set the variable when I hit run for it to work. I tried arming and disarming PLEG and all sorts of other things and the scene was the only thing that worked. I know you can use an underscore with conditions but that didn’t seem to work on inputs.

Lastly, I don’t know if you saw my mention in earlier post about push notifications and the advanced action tab. If you don’t add any actions and just go straight to advanced, you can’t add the push notification. You have to add something else first, add the push notification and then you can delete the other item. No big, just adds steps.

As a musician, sheet music is easy to me ;). Thanks for your help and time!

When you change something in the Advanced Tab for a device of Vera … you need to do a Save (Vera Restart) in order for the change to be recognized.

You should have noticed the Reload button was changed to a Save.

Yeah I did that. Perhaps I didn’t wait long enough for pleg to pick up the change?

Nope, I changed it and saved and it has been about 30 minutes and keep checking the PLEG status page and it still shows a value of false instead of the string value.