Author |
|
logbuilder Newbie
Joined: February 03 2009 Location: United States
Online Status: Offline Posts: 22
|
Posted: February 21 2009 at 17:11 | IP Logged
|
|
|
I've got the following in a formula statement.
I have defined LIGHTS_STATUS as a global. I can set the value just fine with:
ph_setglobal_a ("LIGHTS_STATUS", 2
)
But... when I try to set it in the following statement, it never changes.
ph_setglobal_a ( "LIGHTS_STATUS", ph_getinsteonstat("APPLIANCE_CONTROLLER_1" ) )
After the setglobal statement, here is the conditional GOTO:
if( {LIGHTS_STATUS} = 2 , "EXTEND_WAIT",
"TURN_ON_LIGHTS")
It works fine.
Any ideas on why the ph_getinsteonstat within the ph_setglobal_1 doesn't change LIGHTS_STATUS?
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: February 21 2009 at 18:56 | IP Logged
|
|
|
Your statement works on my system as far as setting the global variable value (using my device ID of course). Global variable is set to a 1 when the device is Off and set to a 2 when the device is On.
ph_setglobal_a ( "LIGHTS_STATUS", ph_getinsteonstat("ICON SWITCH TEST" ) )
Try adding User Message statements to your Macro to view each value individually until you find the unexpected.
"LIGHTS_STATUS Global variable is : " + ph_getglobal_s("LIGHTS_STATUS")
"ICON SWITCH TEST ph_setinsetonstat is: " + ph_getinsteonstat("ICON SWITCH TEST")
Using Powerhome Status, run the Macro and watch the User Message results. Would expect you will find something unexpected.
Edited by grif091 - February 21 2009 at 19:04
__________________ Lee G
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: February 21 2009 at 19:15 | IP Logged
|
|
|
What type of device are you trying to get status from? Perhaps communication with that device is a problem or perhaps it does not support a status query command. Post the type of device you are using and I will try that here if I have one.
__________________ Lee G
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: February 21 2009 at 19:36 | IP Logged
|
|
|
Try this:
ph_setglobal_s ( "LIGHTS_STATUS", ph_getinsteonstat("APPLIANCE_CONTROLLER_1" ) )
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: February 21 2009 at 23:25 | IP Logged
|
|
|
Just do a...
goto | if( ph_getinsteonstat( "APPLIANCE_CONTROLLER_1") = 2 , "EXTEND_WAIT",
"TURN_ON_LIGHTS")
No need for a GV.
|
Back to Top |
|
|
logbuilder Newbie
Joined: February 03 2009 Location: United States
Online Status: Offline Posts: 22
|
Posted: February 22 2009 at 01:45 | IP Logged
|
|
|
Folks,
I've got it working now. The fix is hard to believe but I have found this to be the answer twice now.
I inserted a line just after the one I was having problems with and entered the exact same thing. Then I deleted the line that wasn't working.
Strangely enough, it works. Happened before on a label line. I could not get any goto to recongnize the label. Entered it again, deleted the first and poof, it works.
Thanks for all your help. It caused me to think of the obscure rather than keep thinking that something was wrong with the command itself.
Anyone else had this strange behavior?
Edited by logbuilder - February 22 2009 at 01:46
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: February 22 2009 at 10:11 | IP Logged
|
|
|
For reference, I have not seen that problem. I am running 2.1b. Is there any chance a Save (PF5) may have been missed. That I have been guilty of on more than one occasion. Easy to do when the mind is thinking of the logic being created, moving between the Macro screen and the Formula Builder popup, I forget to press PF5 to make the changes available to runtime. Perhaps you have found a glitch that I had attributed to missing a Save.
__________________ Lee G
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: February 22 2009 at 10:36 | IP Logged
|
|
|
Did this failure happen when you used Formula Builder or when you ran the macro in real time? If you ran it from the RUN window and you had the macro open then the changed line would not execute thus the scenario Lee described. If you closed the macro then ran it we have a potential problem. I tried to duplicate your problem and could not find a fault with what you wrote.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
logbuilder Newbie
Joined: February 03 2009 Location: United States
Online Status: Offline Posts: 22
|
Posted: February 22 2009 at 13:03 | IP Logged
|
|
|
I am building my macro by going to explorer->macros
I enter the commands in the macro detail screen. For formulas, I pick formula as the command and then enter the formula in the last field.
Then I run the macro by causing the trigger to fire which in my case is camera motion sensed by webcamxp.
Is there a better way that might help me with syntax? Seems about the only way I can tell if I have a syntax error is the red message at the bottom of the screen when it runs. The event log doesn't seem to contain anything 'red'.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: February 22 2009 at 13:10 | IP Logged
|
|
|
When you run the macro do you close the window 1st before the trigger fires? Formula errors have to be checked on in Setup under LOGS for the error to appear in the Event Log.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: February 22 2009 at 13:18 | IP Logged
|
|
|
After entering the formula into the last field, or even before, double click on that last field and it will take you to the Formula Builder. Type your formula, then click on Verify. The result is displayed at the bottom of the Formula Builder window. A "!" response indicates a problem with the formula. You can test small pieces of a complex formula. As you get the various pieces working then test the full formula. There are some very rare occasions where a good formula cannot be verified successfully from the Formula Builder. These are documented in the PH user guide or the help facility. I don't remember what those exceptions are, I've never run into them myself. One of the nice things about Formula Builder is as you move the cursor across a complex formula, the colors of "(" change to show matching ")". Common problem is not enough parens or too many. Easy to find this way.
__________________ Lee G
|
Back to Top |
|
|
logbuilder Newbie
Joined: February 03 2009 Location: United States
Online Status: Offline Posts: 22
|
Posted: February 22 2009 at 16:35 | IP Logged
|
|
|
Grif and BeachBum,
Wow, great help! In setup, all was checked except for formula errors. Great catch. And that trick about bring up the formula builder -- priceless.
Thanks so much to both of you!
Robert
Edited by logbuilder - February 22 2009 at 16:36
|
Back to Top |
|
|