Jump to content
C4 Forums | Control4
  • 0

Conditional based on day of year / range of days?


cnicholson

Question

Happy Valentine's Day!   I sat down this morning to do some programming to make all my landscape lights be red tonight.   I currently have a Scheduler event for Sunset everyday where I turn on landscape lights.  I decided I should make a macro that is invoked as part of my Sunset actions "Turn on Landscape Lights" and want to put in some conditionals to kick off different landscape lighting programs based on special days / ranges.  Like Feb 14 every year or Xmas lights between Dec 1 and Dec 30, etc.

I guess I just assumed that there would be a system variable for Current Date and I could drive it off that (hopefully with > and < modifiers).  But I'm not seeing that.  What's the best way to do?  Kludgy idea I had was to create a variable "DaysElapsed" and increment once at midnight (and reset Dec 31) and drive the logic off that by manually computing that Feb 14 is the 45th day of year (or whatever) and using my variable in conditionals.

Is there a better way?

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • 0

More than one road to the same endpoint on that one.

Easiest is to just use basic IF statements.

If you're talking one or two lights, you cna program it directly under the 'sunset' schedule, however it's easier to tack change and adapt if you use different Macros for each option (you can always copy and paste any lighting that doesn't change in to each macro)

 

WHEN scheduled event sunset occurs
	IF current month = february
		IF current day of the month = 14
			Execute Macro Valentine lighting
			STOP
	IF month is November or December {<---yes you can select more than one moth, this seems to not be noticed by many}
		Execute Macro Xmas lighting
		STOP
    IF day of the week is Saturday
    	Execute Macro Party night Lighting
        STOP
  {insert as many as you want in here then END with:}
Execute Macro Standard lighting

All those date commands are available in the standard scheduler in C4.

the STOP commands will ensure that when any one (or any string of) IF statements is 'true' it will execute that macro then stop reading the rest of the script. and by keeping the default at the bottom, if NONE of the IF statements are true, that last line will occur.

 

The biggest downside is that it's not possible to choose things like 'easter' or other holidays that are not calendar/date based. There's also no easy way of choosing, say, the first Monday in a month (yes it's possible but very annoying to do)

Link to comment
Share on other sites

  • 0
35 minutes ago, Cyknight said:

All those date commands are available in the standard scheduler in C4

Awesome.  I will explore more.  I did have the same question as @Shoe in terms of how to literally do this in composer.  Are you firing off scheduler events of like every 14th of month?  I'm still not seeing how to do this directly in Programming.  

Taking cues from @RAV, I have started to do this by using a HolidayState variable that I set to "Valentines" on 12:01am every Feb 14 and then set to "None" at 11:59pm every Feb 14, etc. and then in my Sunset event, I do a series of "If HolidayState=Valentines then [do Valentines stuff], then stop."  With default stuff at bottom

 

 

Link to comment
Share on other sites

  • 0
2 hours ago, cnicholson said:

Awesome.  I will explore more.  I did have the same question as @Shoe in terms of how to literally do this in composer.  Are you firing off scheduler events of like every 14th of month?  I'm still not seeing how to do this directly in Programming.  

Taking cues from @RAV, I have started to do this by using a HolidayState variable that I set to "Valentines" on 12:01am every Feb 14 and then set to "None" at 11:59pm every Feb 14, etc. and then in my Sunset event, I do a series of "If HolidayState=Valentines then [do Valentines stuff], then stop."  With default stuff at bottom

 

 

You can access the if statements for day and month etc. by choosing the scheduler on the right side of composer.

If you want specific holidays like Easter you can use one of the advanced / enhanced scheduler drivers.  I use the Janus one and it is extremely powerful.

Link to comment
Share on other sites

  • 0
6 hours ago, Cyknight said:

Code insert option (<>) and then type it in there: allows proper tabs etc to show IF statement indents etc)

Ah heh... not on the forum software. I was wondering if you could copy the programming from composer to text in this way. I've always found it to be xml. I'm hoping I'm missing a feature where I can type code in composer rather than drag/drop/clicky/clicky. Sorry for the misunderstanding.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.