PLEG light timer help please

@Rhinesel,
Understand your note but… if we wanted a few zones to cycle on/off at different random times I would assume that we do something like this using your code?;

Properties:
pVacationSwitch- Status

Schedues:
sSunsetTo2300RandomOff1- Day of week, interval, start time Sunset, end time 2300 random of 30 minutes
sSunsetTo2300RandomOff2- Day of week, interval, start time Sunset, end time 2300 random of 30 minutes

Conditions:
cVacationLights1On- pVacationSwitch==1 AND sSunsetTo2300RandomOff1
cVacationLights1Off- pVacationSwitch==1 AND !sSunsetTo2300RandomOff1
cVacationLights2On- pVacationSwitch==1 AND sSunsetTo2300RandomOff2
cVacationLights2Off- pVacationSwitch==1 AND !sSunsetTo2300RandomOff2

Actions:
cVacationLights1On- Select the on command for the lights you want on
cVacationLights1Off- Select the off command for the lights you want off
cVacationLights2On- Select the on command for the lights you want on
cVacationLights2Off- Select the off command for the lights you want off

@RHINSEL

Thank you for the example. I will give it a test.
Did you set your conditions as a repeat?

@MNB

Thanks for the addition. I figured that out for additional lights. In fact I would use your example and control 2 lights each for a total of 4 lights.
Right now I am testing 1 light.

If all goes well I well then I will use my DayorNight plugin as the trigger instead of a virtual switch.

Thought about this last night - I think the way to set this up would be to have two schedules - one for the time of day you want it to run (sunset to 23:00 for example), and then a second timer as interval with a random delay on the on and off. I didn’t test this, but it should work nice- you might need to alter the interval time…

Properties:
pVacationSwitch- Status

Schedues:
sSunsetTo2300- Start type Day of week, start time Sunset, End Type Day of Week, end time 2300
sRandomOnOff- Start Type Interval, every 30 minutes, random on delay 10 minutes, End Type Interval, random off delay 10 minutes

Conditions:
cVacationLights1On- LightsOff and pVacationSwitch==1 AND sSunsetTo2300 and sRandomOnOff
cVacationLights1Off- LightsOn and pVacationSwitch==1 AND (!sSunsetTo2300 or !sRandomOnOff)

Actions:
cVacationLights1On- Turn LightsOn
cVacationLights1Off- Turn LightsOff

@wilme2

Looking over your new setup, I think you have it nailed. I am going to set it up and see how it goes. This is more what I was after- to have the lights on AND off during a sched duration. The other examples do a one time cycle of the light (on to off).

Thanks for giving this more thought and posting!

Add a little more to the variety:
sSunsetTo2300- Start type Day of week, start time- 15 Minutes before sunset with 54 Minute random On time
End Type Day of Week, end time 22:30 with 1 hour Random Off time.

You can eliminate one of the conditions:

Conditions:
cVacationLights1- pVacationSwitch==1 AND sSunsetTo2300 and sRandomOnOff

Actions:
cVacationLights1- Using the Advanced tab …
Select Light Device
Action: SetTarget
newTargetValue: {(cVacationLights1 ? 1 : 0)}

[quote=“RichardTSchaefer, post:18, topic:188288”]You can eliminate one of the conditions:

Conditions:
cVacationLights1- pVacationSwitch==1 AND sSunsetTo2300 and sRandomOnOff

Actions:
cVacationLights1- Using the Advanced tab …
Select Light Device
Action: SetTarget
newTargetValue: {(cVacationLights1 ? 1 : 0)}[/quote]

I thought an action for a condition can only fire when the condition is true? I like the simplification (likely overkill unless you have a lot of automated lights as I do) as it will speed up processing, but I don’t see how the off works…

Oops that’s right …
Change to:

cVacationLights1- pVacationSwitch==1 AND sSunsetTo2300 and sRandomOnOff ? 1 : 0

Action:
newTargetValue: {(cVacationLights1)}

When the Condition holds a value … it fires when ever the value changes.

Richard,
This example is using a virtual switch to signify when one is on vacation or not, as UI 7 now has the following modes;

[ul][li]Home[/li]
[li]Away[/li]
[li]Night[/li]
[li]Vacation[/li][/ul]

would it not be better to use use them? and if so how would one use them with this PLEG example, I assume it would no longer be a device property but rather a My Modes > Vacation with a unique name? Mike

Nice work Richard. I just tweaked wilme2’s plan to match yours and testing.

Tell me what starts the sRandomOnOff sched? Testing it and the status report shows it to be false. All else is true, but no lights are turning on.

Also is the condition SunsetTo2300_s1 AND RandomOnOff_s2 ? 1 : 0 ?1:0?

Just a followup on the test of Richards tweak…

I have it working fine. Been testing all day and it is doing fine. So disregard my previous post.

Thank you all for helping me out with this. I think you should include the as an example in your PLEG docs. A lot of people would benefit from this function.

If you want to use MCV modes … you PLEG allows you.
I do not plan on using Vera Modes …
For me I can have
Vacataion, and Vaction + Night, Away, and Away + Night, Home, Home + Night

Alright Richard,
I’m being a little thick… ::), Instead of using the Vera Mode your using virtual switches or are these PLEG inputs for each of you modes?

[ul][li]Vacation,[/li]
[li]Vacation + Night,[/li]
[li]Away,[/li]
[li]Away + Night,[/li]
[li]Home, [/li]
[li]Home + Night[/li][/ul]

I use a Multi-Switch to set modes … that means I can have more than 1 mode active at a time.

Vera’s definition of House modes … being only 1 mode active at a time is to restrictive for me.

Richard,
Thanxs for clarification, I’m assuming that when your on Vacation that you select both; Vacation and Vacation + Night? I would have thought that Vacation + Night could have been solved within a condition statement using Day/Night as an Input, obviously I’m missing something?

The reason I’m asking fundamental questions is that for the novices of us not all things are totally clear (I’m not always seeing the blonde amongst the one’s & Zero’s - Matrix) any help from you is greatly appreciate and helps us make a better HA solution. That’s why I will ask others to post their latest PLEG solutions as they are great working examples/resources to used and modified. Mike

I downloaded DeusExMachina from the official VERA app store, but I’m pretty sure it screwed up my PLEGs. They all came up empty with the error message “ says Error Reading Data”. I restored a backup taken shortly before I installed Deus and the PLEGs came back to normal.

Not Deus, or anything else… PLEG updated itself and there may be issues, see here:

Sincerely sorry @Rigpapa, it was the PLEG 9.1 update that caused the problem and not your Dues.
I have rolled back to PLEG 8.11 using a backup taken a couple of days ago & turned off PLEG auto-update, as per thread.https://community.getvera.com/t/urgent-help-oh-pleg-just-died/215638/2

Please accept my apologies for maligning Dues incorrectly, it was just one of life’s unfortunate co-incidences that it happened immediately after I installed your plugin :blush: (or maybe the downloading of any app triggered the update of another app?)

No worries! I just wanted to make sure you had the info and were aware of the ongoing discussion elsewhere.

It is a curious fact of our world, though, that often the last car over a bridge gets blamed when the bridge collapses…

So true! :thinking: