Author |
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 09:22 | IP Logged
|
|
|
Ok been using PH for about 2 years on the simple stuff and it works great. So now I want to complicat my life. I have an Insteon setup with a few X10 pieces here and there. What I am trying to do is set up so that my back lights go on automatically when movement is detected in the back yard. Simple enough I have all the lights in a Macro to go on, and another Macro set to turn them off. Then I have two triggers set up O1/On of course triggers the Lights On Macro and O1/Off triggers the opposite. Easy enough. Well now to complicate the matter, I only want these Macros to run between say the hours of 9PM and 6AM....help?
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: July 07 2008 at 09:39 | IP Logged
|
|
|
Try this:
Jump If(hour(now())>21,2,1)
Jump If (hour(now())<6,1,999)
Line 3 would be where you turn on your lights.
The first line checks to see if it is between 9 pm and midnight. If it is it jumps to line 3 (the 2nd line after it) and turns on your lights. If not it jumps to the next line.
The second line checks to see if it's earlier than 6 am. If it is, it goes to the next line and turns on the light. If not, it ends the macro (i.e. goes to nonexistent line 999). There are other ways of doing this, but this should work.
Noel
|
Back to Top |
|
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 09:48 | IP Logged
|
|
|
Ok forgive me showing my ignorance, but these lines would go where? In the Trigger or the Macro?
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: July 07 2008 at 10:45 | IP Logged
|
|
|
They'd be the first 2 lines of the macro.
|
Back to Top |
|
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 11:36 | IP Logged
|
|
|
Cool thanks! Seems to be working like intended, escellent!
|
Back to Top |
|
|
judetf Senior Member
Joined: January 23 2008
Online Status: Offline Posts: 234
|
Posted: July 07 2008 at 12:09 | IP Logged
|
|
|
Alternatively (just for the sake of offering options), you could run a timed event at the appropriate times to enable/disable the triggers. That's the method I used in a few instances... That way PH doesn't even bother listening for the triggers to fire and doesn't have to process a macro, even just to jump, unless "it's time."
|
Back to Top |
|
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 12:36 | IP Logged
|
|
|
Ok, let me see if I can figure that one out!
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: July 07 2008 at 14:06 | IP Logged
|
|
|
One other way to do it (my favorite) is using the boolean field of the trigger. Just place the following code in the boolean field:
Code:
if(hour(now()) >= 21 or hour(now()) < 6,1,0) |
|
|
Dave.
|
Back to Top |
|
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 14:37 | IP Logged
|
|
|
dhoward wrote:
One other way to do it (my favorite) is using the boolean field of the trigger. Just place the following code in the boolean field:
Code:
if(hour(now()) >= 21 or hour(now()) < 6,1,0) |
|
|
Dave.
|
|
|
Ok while you guys are all making my head spin with the possibilities let me see if I can get my head around the code... Ok so it starts if the time now is greater than or equal to 9PM or if the time now is before 6AM...that is where I run aground. What is the ,1,0 for? If true return 1 meaning go to the next step or execute, if false return 0 meaning stop?
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: July 07 2008 at 14:55 | IP Logged
|
|
|
Exactly. If 1, the statement is true and run the trigger. If 0, the statement is false and don't run the trigger.
Leave it to Dave to come up with the most elegant, easiest and yet sophisticated solution.
Not being a programmer, I never got my head around using the boolean field. I learned something from this also and it gives me several other ideas......
Noel
|
Back to Top |
|
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 14:59 | IP Logged
|
|
|
Well glad I could help you Noel! Now to the loaded question that I am sure has been asked a thousand times. Is there any quick reference that I can use to understand/decode the code? A cheat sheet per se?
|
Back to Top |
|
|
nadler Super User
Joined: February 25 2006 Location: United States
Online Status: Offline Posts: 354
|
Posted: July 07 2008 at 15:41 | IP Logged
|
|
|
Within PH there is a help file for each PowerHome function. It has an explanation of each function although no examples. Just click on help or Alt-F12.
PowerHome has so many extensive functions that it would probably take a book of 1000 pages to detail them all with examples. For right now, just search the help file, search the board and ask questions.
|
Back to Top |
|
|
edtude Groupie
Joined: July 26 2006 Location: United States
Online Status: Offline Posts: 64
|
Posted: July 07 2008 at 15:50 | IP Logged
|
|
|
Thank ya Kindly
|
Back to Top |
|
|