Using PLEG for an AND condition to trigger a scene

I previously used Combination Switch, Virtual Switch, and Heliotrope to achieve the function. Now on UI7 with Combo switch not work as before, I am looking for alternatives.

I am already licensed for PLEG and have installed Day or Night. Along with VeraAlerts, I figure I’d go all in with Richard.

Desired function:

  1. Starting at dusk and ending at dawn, when 2) motion sensor senses motion, 3) the virtual switch is ‘on’ (or left on), Vera is to turn on a light for 50 seconds. One more thing–I used VeraAlerts to tell me when the motion light turns on.

Previously, I used Heliotrope to determine the time of day (condition 1), motion sensor to provide notice of motion (condition 2), and Virtual Switch to easily enable or disable this Function (condition 3). This way, if I turn off Virtual Switch, motion light will be disabled. When all 3 conditions are met, it triggers a scene to turn on the light, then off after 50 seconds.

----Moving on----

I installed Day or Night. It appears to be a suitable replacement for Heliotrope. I understand that Day or Night uses Vera’s time-of-day data. My Vera’s timezone is properly set.

Question 1: Does Day or Night properly offset for Daylight Savings Time?

Onto PLEG, I am trying to use PLEG to replicate the same function in a “as simplistic as possible” way.

Question 2: In the input section, there is “Triggers” and “Device Properties”. With my scenario above, I presume the motion sensor would be a trigger and the Virtual Switch would be a device property? (Most of the time, I would leave the Virtual Switch enabled.)

Question 3: What would be the syntax to determine the AND conditions (night, motion, V-switch on)?

Question 4: How do I get PLEG to trigger a scene?

Many thanks for any help.

It looks like I would create a scene triggered by a met condition in PLEG. True?

BTW, rts-services.com seems to be down for now…

[quote=“snovvman, post:1, topic:192241”]Question 1: Does Day or Night properly offset for Daylight Savings Time?

Yes, it does.

Question 2: In the input section, there is “Triggers” and “Device Properties”. With my scenario above, I presume the motion sensor would be a trigger and the Virtual Switch would be a device property? (Most of the time, I would leave the Virtual Switch enabled.)

Your VS could be your Trigger, you will need to select the device in the Input - Trigger to make sure you can use it.

Question 3: What would be the syntax to determine the AND conditions (night, motion, V-switch on)?

Break it down into small pieces rather than trying to code it in one line.

Start with Day/Night, then move onto day/night and motion and so forth.
It’s far easier to check your logic in this manner.

Question 4: How do I get PLEG to trigger a scene?

Use Actions

Many thanks for any help.[/quote]

You can do this with JUST PLEG (you only need the Day and Night plugin if you like to manually change your Logic from Day to Night mode, Testing is an example where this is useful).

ALL PLEG Solution:

Input Triggers:
tEnable When your Virtual Switch is in the ENabled positition
tMotion When your motion sensor detects motion

Input Schedules:
sNight On every day at Sunset (offset if you like I typically use Sunset + 15 minutes)
Off every day at Sunrise (offset if you like I typically use Sunrise - 15 minutes)
sLightTimer On set to SelfRetrigger
Off set to Interval of 50 seconds

Logic:
cAutoOn sNight and tMotion and tEnable
cAutoOff cAutoOn;!sLightTimer

Actions:
cAutoOn: Turn On Light
Start the sLightTimer (use advanced Mode, Select the PLEG device, action is StartTimer)
cAutoOff: Turn Off Light

[hr]
If you want to use the Day or Night timer as well, just remove the sNight schedule and create a tNight trigger and update the name in the cAutoOn condition.

[hr]
I believe the Heliotrope app by @Futtzle is more accurate in the higher latitudes (closer to the poles) then the MCV function used by PLEG and Day or Night plugins. Where I live, fixed offsets from Sunrise/Sunset work well all year long for determining ambient light level.

Test then pop open a cerveza!
Please read Rex’s getting started guide to understand the above.

[quote=“RichardTSchaefer, post:4, topic:192241”]Test then pop open a cerveza!
Please read Rex’s getting started guide to understand the above.[/quote]

Cervezas all around! Rex’s guide was a big help. I took the easy way out: Defined 3 triggers 1) virtual switch on, 2) motion sense, 3) Day or Night showing night. Condition set to AND for the 3 triggers. Used a scene to trigger on condition met to turn on light and timer in scene to turn off light. Everything works!

I can now remove Heliotrope and Combination Switch.

Applauded and cheers!