seyler Newbie
Joined: December 27 2001 Location: United States
Online Status: Offline Posts: 9
|
Posted: December 28 2001 at 16:24 | IP Logged
|
|
|
Actually, I've answered my own question. But I thought I would share it, since at this early version of PowerHome there is not a lot in the way of documented samples. What I needed to accomplish was to have a datetime variable set to a specific interval in the future (say 15 minutes.) I originally accomplished this using the secondsafter function. However, if the time is near midnight (say 11:50 pm) then the secondsafter function returns null. I needed to have a variable set to 12:05 am on the next day.
Here is how I accomplished this:
(Note that {OFFICE DURATION} is the time in minutes that I want a particular light to remain on. It is a dynamic variable, dependant on the time of day. {OFFICE OFF TIME} is the variable calculated by this macro which holds the date and time that the light should be turned off. FYI, this function is run every time a motion detector transmits an ON, so the {OFFICE OFF TIME} is continually updated.)
set system
MACRO1
secondsafter(now(),23:59:59)
set system
MACRO2
{OFFICE DURATION}*60
goto label
if([MACRO1]<[MACRO2],"Tomorrow","Today")
label
Today
set global
OFFICE OFF TIME
datetime(today(),relativetime(now(),[MACRO2]))
jump
999
label
Tomorrow
set global
OFFICE OFF TIME
datetime(relativedate(today(),1),relativetime(00:00:00,int([MACRO2])-int([MACRO1])))
If anyone else has interesting macros that they would like to share, I would sure like to see them! I'm trying to come up with creative ways to implement PowerHome.
Regards,
Steve
|