Author Topic: How would I insert a "wait until x time"?  (Read 1741 times)

Frunple

  • Hero Member
  • *****
  • Posts: 774
    • View Profile
How would I insert a "wait until x time"?
« on: November 28, 2010, 06:30:28 am »
If there even is a way.
I'm setting up my xmas lighting scenes and I have a scene set to turn on all my lights, then another scene set to turn them all off.
I want to make a rule that runs the "on" scene at sunset, then WAIT UNTIL 23:59:59 and run the "off" scene.
Can't seem to find a way to do this so I have to create two rules to accomplish this, seems unnecessary.
Thanks

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: How would I insert a "wait until x time"?
« Reply #1 on: November 28, 2010, 10:31:09 am »
While it's not a requirement you generally want to keep rules from running for a long period of time since a power interuption would cause unexpected results

Here are 4 ways to do it with the pros and cons:

1. Using 2 rules would be the most relable way to do it... because if you power cycle to the computer the 2nd rule wil still run (assuming the computer is on).

2. Use 1 rule and use the asynchronous SetLightLevelForDuration method to keep the light on for the specified amount of time. You can set the amount of time to something like 5 hours or you can calculate it using script. If the computer is rebooted during the duration the lights won't turn off.

3. Similar to # you can do the same thing with the SetPropertyForDuration method which is available in all drivers, but the SetLightLevelForDuration method is specialized for lights.

4. Use 1 rule and use the Sleep command to cause the rule to be suspended for a certain amount of time. This is the least desirable way to do it since it blocks the rule from completing for a long time.

We could add a SetPropertyUntilDateTime but you would still need to calculate the date and time to stop. I think what you are really looking for is a SetPropertyUntilTimeToday.
John Hughes
Codecore Technologies

Frunple

  • Hero Member
  • *****
  • Posts: 774
    • View Profile
Re: How would I insert a "wait until x time"?
« Reply #2 on: November 29, 2010, 08:07:32 am »
I guess it's not really that big of a deal, I was just looking for a way to do at the time of making the rule. The two rules are working fine. You bring up a good point about the pc turning off, it wouldn't be able to resync with the rules that were running so creating two rules seems to be the way to go here.

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: How would I insert a "wait until x time"?
« Reply #3 on: November 29, 2010, 08:35:19 pm »
I'm glad it's working for you. :)
John Hughes
Codecore Technologies

mustangcoupe

  • Full Member
  • ***
  • Posts: 108
    • View Profile
Re: How would I insert a "wait until x time"?
« Reply #4 on: December 27, 2010, 06:25:40 am »
not to bring this one back up but can a rule be created from a rule?

one rule that dues stuff, and creates a rule on the fly to fire once, at NOW() + X

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: How would I insert a "wait until x time"?
« Reply #5 on: December 27, 2010, 09:48:33 am »
not to bring this one back up but can a rule be created from a rule?

one rule that dues stuff, and creates a rule on the fly to fire once, at NOW() + X

Rules can not be dynamically created BUT...

Using the Timers driver you can create a timer to elapse in a certain amount of time. You can then create a rule that is triggered by the elapsed timer.
« Last Edit: December 27, 2010, 12:28:26 pm by John Hughes »
John Hughes
Codecore Technologies