PLEG Newbie condition question/guidance

Hi Experts!

Just recently started playing with PLEG and trying to apply to a specific scenario. I have a Vera Edge.

I have outdoor GoControl ZWave floods and a basic scene that turns the floods on at sunset and turns them off in +3 hours. This simple scene is (as one might expect) fine.

I recently added an Aeotec Trisensor, to be used primarily for detecting motion.

I wanted the following scenario:

  • From sunset until +3 hours, have the floods on regardless of motion
  • After +3 hours until sunrise, turn the floods on when motion is detected; turn off floods after 5 min

To test out floodlight control with a motion trigger, I used PLEG to set up a trigger, and then a condition on that motion trigger. Finally a Logic Action to toggle the state of the floodlights with an interval delay of 2 min (just for testing purposes; in normal operation the interval would be 5 min).

When armed, the motion detector turns on the floods as expected, but the lights do not turn off after the interval prescribed. After a few more minutes, triggering the motion sensor causes the lights to be turned off (presumably because the light state is toggled).

Question: Is there anything I ought to be doing differently to ensure that the lights duly turn off as expected?

Question: Since the trisensor also includes a light sensor, would it make sense to extend the condition to include an AND test to check the light level - i.e., if motion is detected AND the light level is less than 10 lux, for example?

Many thanks for your guidance. Greatly appreciated.

Post a Status report so we can see what your logic is.

I agree, a status report. Are you looking when the sensor no longer detects motion? If the sensor sends that signal after 5 minutes, then a simple condition to turn off the lights when motion stops should work. Otherwise you may have to use a timer for the 5 minutes interval. But the status report will tell us a lot about what you trying to do.

Thanks very much for the quick responses. Here is the Status Report PLEG_StatusReport.pdf (66.0 KB)

OK, not much to go on, I’ll give you a nudge to get you started, mind you there are many different ways to approach this, this is one way:

As you have motion already detected I would add the NOW expression in your condition such as tDeckMotion;Now>5.00
Use this to turn the Light OFF

also have a look at the Day/Night plug in, you can set your 3 hour buffer in the settings.

Thanks, zedrally! This is quite helpful, and am looking forward to getting this working right.

I would also suggest that you use the Night/Day Plug In. It has offsets for the 3 hours extra that you ask for.
Get this working first and work on the motion later.

Hi Experts! Thanks to zedrally & phillid2 for their guidance. I did get the deck lights working on motion detection as I wanted:

  1. Detect motion and turn deck lights on
  2. After 5 minutes, turn deck lights off

The next part (for me) is to add a rule for light level, so the above lights turn on/offonly at night.

The attached Status Report shows how I did this. I would beg your indulgence and critique the logic to see if there are other ways to do this, perhaps more efficient?

PLEG_StatusReport.pdf (70.0 KB)

In installed the Day or Night plugin, but I can’t see a device when I try to create a trigger. I restarted my controller just to be sure. The device created shows up in the list of devices, but not seeing it when trying to create a trigger.

After making any changes in PLEG, always remember to do the PLEG Tango.
ie Reload LUA through EDIT Option.

That’s OK, couldn’t be any simpler.

And that is how you gain experience with PLEG and then you can build upon that experience to make your automation grow. Glad to see you playing and learning.

There are a couple of ways to do the deck lights only at night. The easiest without the Day/Night plugin (which I do not use), is to create a schedule. The schedule can be true if after sunset and before sunrise (which would be Night), and you add that schedule to your condition with an AND operator.

And the schedule can be fine tuned - after sunset but not after 11 pm.

Or after sunset and after 11 pm, turn on lights at 50%. All kinds of options.

Thanks! I’m playing with that right now and will share my approach (I’m assuming that you experts may have suggestions to make things work better!).

Hello Experts!

Attached is a Status Report that addresses the following scenario, and I would be grateful for any tips and guidance regarding that.

The scenario:

  • During “evening hours” (sunset to 22:30) turn on all outside lights (i’m expecting all outside lights to turn off at 22:30)
  • From then on, until “daylight”, detect motion and turn on deck lights for 5 min

I wanted to make the condition “cMotionDeckLightsOn” to simply be “cMotionDeckLights”, but for some reason, I was getting Luup errors when I had an expression like this:

tIsNight AND tDeckMotion AND !cLowLuxLights ; NOW>5:00

And so I wound up having “cMotionDeckLightsOn” and “cMotionDeckLightsOff”

Any guidance on this would be greatly appreciated. Thanks a bunchPLEG_StatusReport.pdf|attachment (76.7 KB)

in PLEG debugging, it sometimes helps to convert triggers into conditions.
Then you can see in the Status Report if the triggers are evaluating correctly.
Not saying this is the problem but it’s another way to debug.

Thanks, zedrally! I will try that.

Don’t know anything about that one! Thanks! Will research that.

This is a PLEG forum.

1 Like