Whenever it's a weekday?

Tips and Techniques for using MLServer's Automation Rules
bjdraw
Senior Member
Senior Member
Posts: 246
Joined: Thu May 24, 2007 4:55 pm
Contact:

Whenever it's a weekday?

Postby bjdraw » Sun Dec 09, 2007 11:05 pm

I need to turn on a light every weekday.
I was able to create a rule for weekends, by using
"Whenever currentdayofweek starts with S"

But other than creating four separate rules for M,T,W,F; I don't know how to do every weekday.
Ben Drawbaugh
How good can it be, if it isn't HD?

User avatar
mcascio
Founder
Founder
Posts: 8270
Joined: Tue Jan 28, 2003 4:03 pm
Location: Kenosha, Wi
Contact:

Postby mcascio » Mon Dec 10, 2007 12:04 pm

Ben,

How about creating a second variable to track whether its a weekend.

While you would have to write a rule for each day of the week (aside from the weekend) you could create one variable like isWeekend=true or isWeekend=false.

Then create a final rule based on the isWeekend variable. That way you can use that variable down the road for other things if you need to.
Mario Cascio
Cinemar, Inc.
http://www.cinemaronline.com

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Postby CinemarDave » Mon Dec 10, 2007 7:07 pm

MLDateTime version 1.0.28 introduces two new server variables:
"CurrentDayIsWeekend", and "CurrentDayIsWeekday"
They are set to 0 or 1 when appropriate.

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Postby ricks » Mon Dec 10, 2007 8:20 pm

Now let's get real greedy. Any chance for a "becomes" condition in Server Rules? So instead of saying:

WHEN {{variable}} changes value AND WHEN {{variable}} equals x

It would be nice to say...

WHEN {{varible}} BECOMES x

Just a thought.

Rick

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Postby CinemarDave » Mon Dec 10, 2007 8:45 pm

How is that different than
Whenever {{variable}} equals X

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Postby ricks » Mon Dec 10, 2007 9:32 pm

Basically it combines the "changes value" and "value equals" conditons. So I dont want an event to occur everytime the variable equals x, only when it becomes x.

Just as a real sloppy example,

WHEN {{currentampm}} BECOMES am THEN... happens once at midnight vs. WHEN {{currentampm}} equals am THEN... potential to have the event fire more than once or on start-up, etc or dependng on the trigger, constantly for 12 hours, especially if pollingis being done.

Rick

bjdraw
Senior Member
Senior Member
Posts: 246
Joined: Thu May 24, 2007 4:55 pm
Contact:

Postby bjdraw » Mon Dec 10, 2007 10:23 pm

This is perfect thanks!
Ben Drawbaugh

How good can it be, if it isn't HD?


Return to “Automation Rules”

Who is online

Users browsing this forum: No registered users and 1 guest