PLEG schedule question

Here is what i would like to do… sounds easy but it isnt…

I would like a condition (lets call it a) to become true weekdays between 22.00 and 5.00, another weekends between 22.30 and 7.00 (using pleg schedule?)
The problem (as far as i understand so far) is that a pleg schedule will return a true just for the second when it is weekday and 22.00.
I have tested this, with a schedule with my times, and a condition to test it. Pleg will turn true at 22.00, that part works, but it will not turn it off at 5.00, although it looks as if i can set ‘on/off’ times in schedule
So to get round this problem, my idea is to have this condition, lets call it aOn, be a variable, which turns to 1 or true at 22.00, and turns to 0 at 5.00 the next morning. I know pleg can now handle variables, would that not be a way to have a condition become true (or 1) between set times ? then i could have another condition for other days of the week where i can have different times

You should be able to achieve this with a sequence expression. Given the schedules:

WDOn (Weekdays, on time)
WDOff (Weekdays, off time)

Condition WDIsOn (WDOff; WDOn) Should be true between WDOn and WDOff.

This could also be achieved using LogicTimer to assist PLEG. See: [url=,15793.0.html],15793.0.html[/url]

LogicTimer provides properties for day-of-week and also weekend. You can use these to calculate the on and off times and then set timers appropriately. For example:

Set a schedule At0305 to run every day at 0305.
Set a trigger TimerEnded for LogicTimer has ended.
Set a property DOW for LogicTimer DOW.
Set a property Flag for LogicTimer Flag.

_StartTime (223600) + (((DOW == 1) or (DOW == 7)) * 1800) <Seconds: 22:00 on weekdays, 22:30 at weekends>
_StopTime (5
3600) + (((DOW == 1) or (DOW == 7)) * 2 * 3600) <Seconds: 05:00 on weekdays, 07:00 at weekends>
_StartTimer At0305
DoOn TimerEnded and (Flag eq “DoOn”)
DoOff TimerEnded and (Flag eq “DoOff”)

_StartTimer LogicTimer Start Timer newTimerCmd=A {(_StartTime)} F DoOn
LogicTimer Start Timer newTimerCmd=A {(_StopTime)} F DoOff
LogicTimer Set Flag newFlag=Finished

I am using DOW in preference to Weekend because, otherwise, you have to wait for the beginning or end of the next weekend to get the timer values to calculate the first time. DOW changes at 00:00 every day so you don’t have so long to wait.

Thanks very much, i think i need a little while to digest that. But will try tomorrow, too late for me now, have been programming other stuff on PLEG… But having had a quick look i think it makes sense. But dont think i would have had any chance to get there on my own
So really appreciate your effort !


I have tried your first solution as it looks the easiest. Thought i understood, but i think i am making a mistake somewhere. Looking at my status, in schedules, weekdayOn and Off seem to trigger at the time i have set, that seems to be working fine, but in conditions, it has not been triggered, although it should have ? I had this condition first like this: WDIsOn (WeekdayOff;WeekdayOn), then looked at your post again and added a space, so maybe it will trigger tonight but i am not sure that really was the problem ?

Update: It seems to be working now. Dont know why it did not work before. maybe it wanted that space between the 2 conditions.

Apparently I don’t understand PLEG schedules.

I want an alert when my motion detector fires between midnight and 5:00 AM

Attached is my status. It fires when there is motion regardless of the time of day.

The Trigger is RoomMotion
The condition is Room_Motion

Delete your existing schedules.

Create a new one called Sleep as follows:
On Time Monday → Sunday at 00:00:00
Off Time Monday → Sunday at 05:30:00

Change Room_Motion condition to:
RoomMotion and Sleep

Thanks, that’s how I had it originally (or at least thought I did). I tested so the one period was now but never got an alert.

I changed it back (no alert) and attached the status.

open PLEG, select your Sleep schedule and press “Do It Now” It will toggle the timer to True

You won’t until the schedules fire and set the state properly.

You can manually toggle the triggers with the DoItNow button in Inputs → Triggers.
Check the Status before and after to see what it is doing.

Thanks guys for your help. I think I understand this now.

Once I set the start/times in the schedule I need to “set” the state to reflect the actual time as compared to the state using the DoItNow button.
It seems to be working now.