Author Topic: Question on events relative to sunrise!  (Read 1259 times)

Deane Johnson

  • Guest
Question on events relative to sunrise!
« on: July 06, 2010, 05:55:32 pm »
I'm wondering about scheduling events a certain length of time after sunrise.  I have motorized blinds that drop as the sun hits the windows.  There are trees in the way much of the year, so the need for blinds occurs anywhere from 30 minutes to 90 minutes after sunrise.  I don't like them down sooner than necessary, as I don't like living in a cave.

Is there a way in Elve to offset the action from actual sunrise?

If I need a different offset each day, would I need to put 365 rules into effect?

My Ocelot now does this function, and I do indeed use 365 lines of instructions, having spent several years logging the times.

Deane

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Question on events relative to sunrise!
« Reply #1 on: July 06, 2010, 10:01:51 pm »
You can use the Date/Time driver's At Sunrise event to start a Timer and then use the Timer's Elapsed event to trigger the action. 
 The Sunrise event does not currently support an offset, and if it did then you would need 365 rules.

Is there any mathematical pattern to your offsets by day? If you can get something close then you could implement this with 2 rules.

Rule 1: Date/Time driver's Sunrise event. The action list should create a named timer using the Timers driver. You can use scripting and a formula based on the day of the year to calculate the amount of offset.

Rule 2: Timer driver's Elapsed event for the named timer you created in rule 1. This is where you would activate your blinds.
John Hughes
Codecore Technologies

Deane Johnson

  • Guest
Re: Question on events relative to sunrise!
« Reply #2 on: July 07, 2010, 04:30:34 am »
I don't think there would be any relevancy to time that could be calculated since timing depends on sun position relative to trees.

I'm thinking the best solution might be to take a sunrise chart, add my current offsets, and establish an actual clock time for each day, then program 365 rules.  That's basically what I'm doing now, but simply programming a number of minutes of off set for each of the 365 days instead of an actual time.

I'm assuming from our discussion that 365 rules would not be somehow cumbersome or excessive for Elve, effecting performance in some manner.

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Question on events relative to sunrise!
« Reply #3 on: July 07, 2010, 05:01:51 pm »
Wow, 365 rules seems like major overkill and a nighmare to set up.  I would recommend using the above technique and use a script to determine the offset.

Something like:

Code: [Select]
day = DateTime.Now.Day; // the day of the year 1-365ish
offset = 0; // the # of minutes to fire after sunrise

// Set the offset based on the day of year.
if (day == 0) offset = 5;
else if (day == 1) offset = 5;
else if (day == 2) offset = 6;
else if (day == 3) offset = 8;
//...

Timers.StartTimer( "Blinds_Timer", offset * 1000 );

This would be much easier to manage. Then you would have a second rule that waits for the timer driver's "Blinds_Timer" timer to elapse.

Are you sure there is no formula? It seems like you should be able to analyze the offsets by day of the year and see some kind of pattern.
John Hughes
Codecore Technologies