Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: crate trigger for certain day Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: December 09 2004 at 22:43 | IP Logged Quote npavkov

I am interested in setting up a trigger or timed event to control the xmas lites each year. I would like to set a variable "on" when the day passes say november 27th (of each year) and "off" when the date passes say January 3rd (of each year). How might I do this??? I would like to have a variable control the turning on and off the xmas lites every year without having to manually set it each year. Can anyone help with the trigger or formula I might use????    Thanks again.
Back to Top View npavkov's Profile Search for other posts by npavkov
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 10 2004 at 14:50 | IP Logged Quote dhoward

Nick,

There are a couple of ways you can do this.

You could create a timed event with a "Reference Time" of 11/27/2004 with a yearly frequency. The "Frequency" field has dropdown selections for common frequencies but you can type any frequency in minutes. There are 60 minutes in an hour, 24 hours in a day, 365 days a year for a frequency of 525600. You could then have the action of the timed event set a global variable for you. You could then also create a similar timed event for 01/03/2005 with a yearly frequency of 525600 to turn the variable "off". While this would work, leap years would throw this off a day.

The second way to do this would be to have a timed event that executes daily. I have one that executes everyday at 00:30. I have it call my "DAILY MACRO" which then in turn calculates whatever needs to be done on a daily basis. You could have a couple of lines that check the current date and if it's greater than or equal to 11/27 then turn the variable on or if it's greater than or equal to 01/03 then turn the variable off. This could be boiled down the formula below. This formula assumes you have a global variable called "CHRISTMAS" and will be set to 1 between 11/27 and 01/03 and 0 outside of that range:

ph_setglobal_a("CHRISTMAS",if(today() > date(string(year(today())) + "-11-27") or today() < date(string(year(today())) + "-01-03"),1,0))

It may be a little hard to follow, but if you take the time and think about how the date checking is done, you'll see that it makes sense.

Let me know if you need more help or I didnt answer it right.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum