PLEG monitoring multiple devices

I have a situation where i have three lights that I want to turn off after 2 hours. I am using PLEG and have been able to monitor one of the lights to turn them all off, but I really want to check to see if any of the lights have been on for 2 hours and turn them off. I have tried several different Conditions and most return null and do nothing. Am I missing some syntax in the condition statement that would check the status of all three lights? (the below examples are set to 2 minutes for testing).

Trigger:
tlightKiton (Kitchen outlet is on)
tlightDinon (Dining outlet is on)
tlightMBRon (Master outlet is on)

Conditions:
c2hrlightoff:
(tlightKiton or tlightDinon or tlightMBRon) and ((tlightKiton or tlightDinon or tlightMBRon);NOW > 00:02:00)

Action:
clightoff (Turns all outlets off)

When I use these conditions, I have mixed results…
Turns off immediately
tlightKiton or tlightDinon or tlightMBRon and ((tlightKiton;NOW > 00:02:00) or (tlightMBRon;NOW > 00:02:00) or (tlightDinon;NOW > 00:02:00))

Does not turn off - null
tlightKiton or tlightDinon or tlightMBRon and (tlightDinon;NOW > 00:02:00))

null - does not turn off
tlightKiton and tlightDinon and tlightMBRon and (tlightDinon;NOW > 00:02:00))

works but only monitors one light
tlightDinon and (tlightDinon;NOW > 02:00:00)

[quote=“ceskelund, post:1, topic:198450”]Conditions:
c2hrlightoff:
(tlightKiton or tlightDinon or tlightMBRon) and ((tlightKiton or tlightDinon or tlightMBRon);NOW > 00:02:00)[/quote]

Terms of sequence expressions can’t themselves be expressions. For this to work you need a previously defined condition such as:

cALightIsOn tlightKiton or tlightDinon or tlightMBRon

and use cALightIsOn as the first term in the sequence expression.

If you haven’t already, you may want to review PLEG Basics in the 2nd sticky thread for more detail about sequence expressions.

Something else you might want to consider is using a schedule (timer) rather than evaluating against NOW. Using NOW causes the conditions to be evaluated every 1 minute. Some PLEG users prefer to avoid using it to reduce processing overhead. Using the above, the action for cAlightIsOn could be to start a 2 hour schedule and a second condition has an action to turn off all 3 lights and evaluates as true when the schedule (timer) expires.

That is great information - thank you.

As far as the timer goes, are those in PLEG affected by Vera restarts? I am getting away from the scenes for this reason and was wondering if they would survive a restart or even a reboot.

Yes this type of timer will survive a restart. There is an issue with absolute schedules that Richard has been working on but that’s a different thing. http://forum.micasaverde.com/index.php/topic,31009.0.html

One more thing - I understand what you mean when you say “Using NOW causes the conditions to be evaluated every 1 minute” but does it only start evaluating when the condition is true (i.e. one of the lights are turned on) or does it continuously evaluate (i.e. constantly checking to see if the condition becomes/is true)?

Hope that makes sense.

My understanding is it causes reevaluation every 1 minute 24/7/365. Someone with more experience will hopefully confirm or correct me if wrong.

That is my understanding as well. OK to use Now() to get things up and running, but long-term you will want to convert to timers…