Author |
|
Deano Groupie
Joined: February 19 2003 Location: United States
Online Status: Offline Posts: 75
|
Posted: February 19 2003 at 11:49 | IP Logged
|
|
|
Hello PH_World,
I am evaluating PowerHome and Home Control Assistant at this time. I can't imagine two applications futher apart. Flexibility and user friendlyness always seem to by inversly proportional in the computer biz.
I have recently install a mr26a and I am very pleased with the performance so far but it does miss a transmission ocasionally which brings me to the problem.
I would like to turn on a light when I see motion but not continue to flood the power line with more on commands everytime ms13a sees motion. This part is easy, I just check status of light and or light sensor in ms13a and don't send another on command if the light is on. The ms13a only sends one off command when it times out. I am afraid of missing it and I would rather not mess with reprogramming the little bugger when I change batteries anyway. What I would like to do is turn the light off after I don't see motion for 15 min.
My first attemt was to use delay in my macro and you all know what that did I thought PH had died. Then I read the book and learned that I was to use Wait instead of delay which I did, but Wait does not get reset when the macro is called (invoked) again ( or so it appears) because when the WAIT times out futher motion causes the light to go on and off repeatedly.
Macro looks like this:
jump if (on,2,1)
on macro
wait 300 (5 min)
off macro
I'm sure there is a simple solution to this but I'm blinded by the light and multiple evaluations.
Thanks for the help
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: February 19 2003 at 15:23 | IP Logged
|
|
|
Deano,
Welcome to the world of PowerHome !!
Your solution is close...just needs a couple of minor tweaks to achieve the effect you want. The problem that you're seeing with your macro is that you are executing the macro multiple times, each with its own "wait". You need to make sure that the macro basically "waits" only a single time with a way to update the amount of waiting. Below is a simple macro outlining the way to accomplish what you want. In addition to the macro, you also need a global variable to keep track of the time for when the light is supposed to turn off. In my macro below, Im using a GV named "MS13ATIME".
10 Set System [LOCAL1] {MS13ATIME} 20 Set Global MS13ATIME string(relativetime(now(),900),"hh:mm:ss") 30 Jump if("[LOCAL1]" = "0",1,999) 40 Wait secondsafter(now(),{MS13ATIME}) 50 Jump if(now() > {MS13ATIME}, 1, - 1) 60 Set Global MS13ATIME 0
The GV {MS13ATIME} should be initialized to 0. The first time the macro is run, it will store the current value of {MS13ATIME} in the [LOCAL1] system variable. We then set the {MS13ATIME} variable to 15 minutes (900 seconds) in the future. In line 30, we'll check the value of [LOCAL1] to determine if the macro is already waiting (MS13ATIME <> 0) and exit the macro if we are. If we are not already waiting, then calculate how long we should wait by calculating the number of seconds between the current time and the time the light should be turned off ({MS13ATIME}). After were done waiting, check and see if the {MS13ATIME} variable was updated while we were waiting (line 50). If it was, jump back and calculate how long we should again. If it wasn't, set the {MS13ATIME} variable to 0 and were ready for another iteration.
As a side note, the next version will have a new function (ph_ismacrowaiting) which will let you know if the specified macro is currently waiting or not.
Hope this helps,
Dave.
|
Back to Top |
|
|
Deano Groupie
Joined: February 19 2003 Location: United States
Online Status: Offline Posts: 75
|
Posted: February 19 2003 at 17:40 | IP Logged
|
|
|
Dave,
Thanks for the prompt response. I'll give a try tomorrow.
Dean
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 19 2003 at 23:17 | IP Logged
|
|
|
Dave,
Is this a better way to do it than what you gave me before (motion and motion expire creating timed events)?
Tony
|
Back to Top |
|
|
Deano Groupie
Joined: February 19 2003 Location: United States
Online Status: Offline Posts: 75
|
Posted: February 20 2003 at 13:15 | IP Logged
|
|
|
Dave,
Thanks again for the PH lesson. There must be a gazillion ways to skin a PowerHome cat After studing the solution you sent, and reading a little more this is what I did:
10 SET GLOBAL BASEMENT MOTION -2
20 JUMP IF([X10STATI1] > 1,999,1)
30 MACRO LIGHTS ON IMMEDIATE
40 SET GLOBAL BASEMENT MOTION 1
50 WAIT 900
60 JUMP {BASEMENT MOTION}
70 MACRO LIGHTS OFF POST
It's pretty simple and seems to be working corectly so far
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: February 20 2003 at 14:11 | IP Logged
|
|
|
Tony,
Either way will work. The next release has a new function which will allow you to call a macro and pass values to its local variables. This will allow me to create a single "Wait" type macro to be used to handle all wait type functions similar to the described. So it's probably the way I'll start to migrate my own code.
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: February 20 2003 at 14:20 | IP Logged
|
|
|
Deano,
Yep, your solution will work as well. The only problem would be that the "LIGHTS OFF" macro may not always execute 15 minutes after the last "On" command. For example...if the macro is halfway through "waiting" and another "on" command is received, you'll set your {BASEMENT MOTION} GV to a -2. When the "wait" command finally times out, you'll start another "wait" for 15 minutes, which would be however long after the original "wait" command finished. But, it does solve the problem of multiple macros waiting and causing your light to flash .
You're right, there are a multitude of ways to solve this problem. In the past, Ive recommended using the "Create Timed Event" macro command to do the waiting as Tony pointed out which is another way it can be done.
BTW, in your original post...which application was user-friendly and which one was flexible ?
Good luck with your testing,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 05 2003 at 20:49 | IP Logged
|
|
|
Any chance of seeing the updated version of these? I'm trying to figure it out now...
Tony
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 06 2003 at 02:06 | IP Logged
|
|
|
OK! Dave's and Deano's method fail when the delay would put it past midnight. I'm trying to fix that now.
Tony
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 08 2003 at 11:52 | IP Logged
|
|
|
Tony,
WOW, a blast from the past. Using the beta, I would now accomplish this the following way:
First declare a macro for this light. Say its a hall light so I'll call it "HALL LIGHT ON". We'll then call this macro everytime the motion sensor see's an "ON" command.
The "HALL LIGHT ON" macro would be as follows:
10 Jump if(ph_ismacrowaiting("HALL LIGHT ON") > 0,1,3) 20 Formula Immediate ph_extendmacrowait("HALL LIGHT ON",900,0) 30 Jump 999 40 Wait 900 50 X-10 1 .......The commands to turn off the light
Basically, the first line checks to see if the macro is already waiting. If it is, we jump down 1 line and extend the macro wait from the current time by 15 minutes. We then jump out of the macro on the next line. If the macro isn't already waiting, we jump down to line 40 and wait for 15 minutes. After the wait time has expired (which could have been extended multiple times), the commands that actually turn off the light are executed.
This method will not have any problems with midnight, etc.
This is how I would currently tackle the problem.
Hope this helps,
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 15 2003 at 20:58 | IP Logged
|
|
|
I assume you meant to put an actual On command in there?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 17 2003 at 10:40 | IP Logged
|
|
|
Tony,
Duhhhhhh...Nice catch. Yes, Line 40 should actually be the "ON" commands for the light. Then wait for 15 minutes, then turn the light off.
I must have been sleeping .
Dave.
|
Back to Top |
|
|