Author |
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 12 2009 at 12:00 | IP Logged
|
|
|
Previously I was helped to setup an insteon light switch controlled by a x10 motion sensor see post: http://www.power-home.com/forum/forum_posts.asp?TID=2027&PN= 1
This basically turned on/off the light based on whether there was motion.
I would like to take this a step further and add the dusk/dawn control. I would like to see the dusk/dawn control when the motion sensor can trigger on/off the light.
Thanks
Edited by williammanda - January 12 2009 at 12:01
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 12 2009 at 12:12 | IP Logged
|
|
|
You can use an IF statement like IF (NOW() < RELATIVETIME( 00:00:00, [DUSK]) , 1, 0) and change the DUSK to DAWN and change the 0 and 1 to conform to a jump in a macro. I don’t know if you are trying to control the trigger or use it in a macro.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 12 2009 at 12:38 | IP Logged
|
|
|
BeachBum
The if statement seems straight forward - if(variable to test,then,else) but I don't understand the functions in the if statement. Is there info on these somewhere? If not could you explain them a little further.
Also I have no idea whether to control a trigger or use a macro.
Thanks
Edited by williammanda - January 12 2009 at 12:39
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 12 2009 at 13:13 | IP Logged
|
|
|
The if statement is a conditional test which you use to satisfy a condition in a macro in the formula of a JUMP or a GOTO Label. In a trigger it would be used in the Boolean to satisfy whether a trigger is to fire or not. A Trigger is usually used to do something as a result of something else happening. Such as a motion detector sending an X10 signal in to the PLM. You would use the trigger to start a macro that might turn on/off you lights and those conditions could be based on whether a condition (IF) was satisfied or not. I don’t know if this is the level you’re looking for or not.
Here are a few excerpts from Dave:
“Macros. This is where a lot of the power of PowerHome takes place. Macros allow you to define a sequence of actions you would like to have performed. This can be turning a light on or off, speaking a phrase using TTS, setting or reading variables, etc. The sequence of steps can be a simple sequence that is executed in order from top to bottom or can include conditional commands to cause certains steps to executed sometimes and not others.”
“Triggers. This is where you define what PowerHome does in response to some external action. If you have a palm pad control and you want PowerHome to do something when it receives a B1 On command, then you would define a trigger. When a trigger condition is met, it can perform a macro or formula.”
“Timed Events. This section allows you to define actions that occur based upon the time of day. If you need an event to occur based upon a specific time, then you would setup a timed event. A timed event can be a "One Shot" that occurs 1 time and goes away or can be set to recur on a specific basis such as every 10 minutes. This section also provides additional controls such as the ability to add random values to the time or have the timed event occur on only certain days or at sunset or sunrise.”
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: January 12 2009 at 14:08 | IP Logged
|
|
|
The question of whether to put the if in a trigger or in a marco is personal choice. The beauty and curse of Powerhome is that things can be done multiple ways with the same result.
If the trigger is performing a simple function keep it simple and use a trigger with the Boolean field containing an if to gate whether the trigger is going to perform its function. A 1 in the Boolean field says do it, a 0 in the Boolean field says don't do it. When what you want to accomplish becomes more complex, like turning on or off multiple devices or doing more complex logic it is easier to put multiple lines in a macro than try to string a complex result in a single formula line. Just my opinion. As with the many ways PowerHome can do a particular task, others will have a different opinion. You do what you are most comfortable doing. Use what you know or use what you want to learn something about so that you can take advantage of that new thing in the future.
Ask a suggestion only, define the trigger to fire on the X10 event, invoking a macro to do the function of turning on and off devices, using the Boolean field in the trigger to check for DUSK/DAWN (what ever gating you want to perform). The DUSK/DAWN checks can certainly be done in a macro but the advantage of putting the check in the trigger Boolean field is that the macro will not be invoked if the trigger event does not occur during the time frame you want the macro function to execute. The advantage of using the macro to execute the function part (device control) is that you can take advantage of macro features. I think it is easier to control X10 and Insteon devices from within a macro but that is also just my opinion. I'm sure others will feel differently. The beauty and curse of PowerHome. I say that with affection because I think PowerHome is the greatest thing since sliced bread.
Hey, sand in the shoes guy, what do you think?
__________________ Lee G
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 12 2009 at 14:28 | IP Logged
|
|
|
My grey haired friend, you were always more elegant. Well put.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 12 2009 at 15:39 | IP Logged
|
|
|
Lee
Can you walk me through both ways, mainly from a learning standpoint for me. Sorry to bother you but I learn better from examples.
Thanks
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: January 12 2009 at 17:12 | IP Logged
|
|
|
An if statement has three parameters. The first parameter is evaluated for True/False. If evaluated True the second parameter value is returned. If evaluated False the third parameter is returned. This information can be found in the Help section of PowerHome.
The following if was taken from the PowerHome Programming – Topic - Simple Help With Now()
This if statement checks the current time (NOW) against the range of 22:00 to SUNRISE, returning a 1 if True and a 0 if False. With whatever adjustment you need to match the time range you want for your situation, place this in the Boolean field of the Trigger. If NOW is not within the selected time range, the Trigger will not perform the defined action because the if returns a 0 (FALSE) which prevents the trigger from performing the action.
if(HOUR(NOW())>= 22 OR NOW() < RELATIVETIME(00:00:00, [SUNRISE]), 1, 0)
If you want to put a similar check in a macro one way would be to code a macro Goto Label command at the beginning of the macro, using the following if in the Formula field.
if(HOUR(NOW())>= 22 OR NOW() < RELATIVETIME(00:00:00, [SUNRISE]),”CONTINUE”,”ENDMACRO”)
If NOW is within the time range a string value of “CONTINUE” is returned and would be a macro Label ahead of the functional code. If NOW is outside the time range a string value of “ENDMACRO” would be returned and would be a macro Label at the very end of the macro, causing all the functional processing to be bypassed.
__________________ Lee G
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 12 2009 at 18:47 | IP Logged
|
|
|
Lee
I really appreciate the effort to help me. I made a couple of small changes to the trigger macro to get it to stay off between 10 pm and sunset:
if(HOUR(NOW())>= 22 OR NOW() < RELATIVETIME(00:00:00, [SUNSET]), 0, 1)
I guessed at sunset because I couldn't find it under help/function. I saw hour and relativetime but not sunset.
Also when you complete the changes, pressing F5 or selecting the F5/refreash icon should save the changes correct?
I will play the macro later but where do I goto to create a macro?
Thanks
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: January 12 2009 at 19:58 | IP Logged
|
|
|
To create a Macro go to PH Explorer and click on Macro then in the right window right click insert. From there you give it an ID (name). After that click on the left little square and the blank Macro will appear. From that point is where you build your macro.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|