Author |
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 19 2009 at 09:37 | IP Logged
|
|
|
Thanks for the help but I still get an error in the event log whether I use your code or Dave's.
Event log error:
Syntax Error in Formula: ph_setccobjbcolor(~"MASTERBEDROOMLIGHT~",~"GB1N~",case(when 0 then 8421504 else 65535))
Using this code:
Code:
ph_setccobjbcolor("MASTERBEDROOMLIGHT","GB1N",case(when 0 then 8421504 else 65535)) |
|
|
Event log error:
Syntax Error in Formula: ph_setccobjbcolor(~"MASTERBEDROOMLIGHT~",~"GB1N~",case( when 0 then 8421504 else 65535))
Using this code:
Code:
ph_setccobjbcolor("MASTERBEDROOMLIGHT","GB1N",case([LOCAL10] when 0 then 8421504 else 65535)) |
|
|
Trigger info for TEST1:
Control center info:
I'm trying to use this trigger on an existing button created by the wizard. Do I need to use a new button? How do I create a new button for the control center (I can't find it in the forums)?
Thanks
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: January 19 2009 at 13:06 | IP Logged
|
|
|
williammanda -
Your Code:
ph_setccobjbcolor("MASTERBEDROOMLIGHT","GB1N",case(when 0 then 8421504 else 65535))
is missing an initial 'expression' term for the CASE function. You must have a value to test for the subsequent when/else tests to function.
Here is a correct case example:
Code:
case(ph_getinsteonlevel("MASTERBEDROOMLIGHT")
when 0 then "OFF"
else "ON") |
|
|
that might be used in a GoToLabel macro.
Also in your macro it seems to me that you are using the bedroom light ID for what should be the Tab ID in the CC. I'm guessing that would be more like 'BedRoom" and not 'BedRoom Light"
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: January 19 2009 at 13:21 | IP Logged
|
|
|
Quote:
I'm trying to use this trigger on an existing button created by the wizard. Do I need to use a new button? How do I create a new button for the control center... |
|
|
The Action macro should be used on the button you want to have an associated activity. For instance here is my Shop Lite button in the CC...
The Shop button is highlighted with a white box when you select it and the Control Center Object Properties window will reflect the ID and Type of Object it is. In this case the button ID is "OSHOP" and it is an action graphic.
Clicking on the "Action" Tab of the Properties window shows additional detail on the OBject
Here we see there is a Raw Formula associated with the Object and the formula is revealed in full when you click on the Formula Editor button. In my case I called several macros to take actions.
To create a new button or object just open the Properties Window and select the ID Tab. Then assign a name to your object and click on the "New" button
Your new object will appear in the upper left of your CC Window as a small rectangle with a white border. It will be selected by default, so you can then assign Actions, Borders, GRaphics, etc.
NOTE that once you create a object that you want to use repeatedly, just select the object, enter an ID in the field to the left of the Copy button, and then click on Copy. You don't need to enter a Type as it will be identical to the original.
Hopefully this gets you going a bit more.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 19 2009 at 13:39 | IP Logged
|
|
|
Ken
I'm totally confused. I followed this post to get the status of the lights (used macro in bold):
[QUOTE=dhoward] Niels,
Welcome to PowerHome! Glad you like the software so far.
Automatic support for what you want is in the works, but in the meantime, it can be done simply enough with a trigger and a couple of functions.
The first thing to do is create a trigger for the light you wish to monitor. Im going to call this trigger "LIGHT1" but you can substitute appropriate ID's as you see fit. The trigger definition would be:
LIGHT1
Light1 Status Change
Raw Formula
ph_setccobjbcolor("CC_TAB_ID_OF_BUTTON","CC_BUTTON_ID_OF_LIG HT",case([LOCAL10] when 0 then 8421504 else 65535))
Enabled
Insteon Device Chg
ID_OF_LIGHT
1
(Any)
1
That's it. You'll just need to substitute in the appropriate ID's of your devices and it should work. The only other thing you may want to add is a trigger for "System Process" / "CC Refresh" to set the initial background colors for the buttons anytime the CC is refreshed or initialized.
Good luck and let me know if you have any other questions or problems.
Dave.
Now either you are giving me something totally different or it is an addition to the original macro.
Code:
case(ph_getinsteonlevel("MASTERBEDROOMLIGHT")
when 0 then "OFF"
else "ON") |
|
|
Please clarify and post an example.
that might be used in a GoToLabel macro What does this mean?
Also in your macro it seems to me that you are using the bedroom light ID for what should be the Tab ID in the CC. I'm guessing that would be more like 'BedRoom" and not 'BedRoom Light" You lost me here. The CC tab ID = MASTERBEDROOMLIGHT and the button ID is GB1N which were all generated by the wizard. Please use the variable names I have used to be more clear.
Thanks
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 19 2009 at 14:02 | IP Logged
|
|
|
GadgetGuy wrote:
Quote:
I'm trying to use this trigger on an existing button created by the wizard. Do I need to use a new button? How do I create a new button for the control center... |
|
|
The Action macro should be used on the button you want to have an associated activity. For instance here is my Shop Lite button in the CC...
The Shop button is highlighted with a white box when you select it and the Control Center Object Properties window will reflect the ID and Type of Object it is. In this case the button ID is "OSHOP" and it is an action graphic.
Clicking on the "Action" Tab of the Properties window shows additional detail on the OBject
Here we see there is a Raw Formula associated with the Object and the formula is revealed in full when you click on the Formula Editor button. In my case I called several macros to take actions.
To create a new button or object just open the Properties Window and select the ID Tab. Then assign a name to your object and click on the "New" button
Your new object will appear in the upper left of your CC Window as a small rectangle with a white border. It will be selected by default, so you can then assign Actions, Borders, GRaphics, etc.
NOTE that once you create a object that you want to use repeatedly, just select the object, enter an ID in the field to the left of the Copy button, and then click on Copy. You don't need to enter a Type as it will be identical to the original.
Hopefully this gets you going a bit more. |
|
|
Thank for the info, very informative!
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: January 19 2009 at 14:18 | IP Logged
|
|
|
Sorry to be confusing. That's not much help for you!
Since I didn't know what your Tab names was (but looking at your image captures now, I see it) I didn't want to confuse you by using your names but in the wrong way.
Taking the example from the forum that you used as a prototype (repeated here for clarity)...
LIGHT1
Light1 Status Change
Raw Formula
ph_setccobjbcolor("CC_TAB_ID_OF_BUTTON","CC_BUTTON_ID_OF_LIG HT",case([LOCAL10] when 0 then 8421504 else 65535))
Enabled
Insteon Device Chg
ID_OF_LIGHT
1
(Any)
1
We would have for the object color line (using your names):
ph_setccobjbcolor("MASTERBEDROOMLIGHT","GB1N",case(TEST_VAR_NEEDED_HERE when 0 then 8421504 else 65535))
You are OK with most of your entry but you are missing the variable to be tested for a zero value.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: January 19 2009 at 14:31 | IP Logged
|
|
|
Quote:
either you are giving me something totally different or it is an addition to the original macro.
Code:
case(ph_getinsteonlevel("MASTERBEDROOMLIGHT")
when 0 then "OFF"
else "ON")
Please clarify and post an example.
that might be used in a GoToLabel macro What does this mean?
|
|
|
Example posted in forum entry above.
A 'Goto Label' is a mechanism that allows you to control the execution pathes of your macros (typically called a Jump commmand in other languages)
In the example below ...
line 80 is defined as a Goto Label in the Command Column. Then in the Formula Column a label is computed using the case function (this is the sample I used in the reply above. It had nothing to do with your effort, it was just a case example). Since labels are strings, the value returned in a Goto must be a string name (thus the quotes around it) that matches up to an entry point name defined by a 'Label' Command (line 100).
While PH has a 'Jump' function, it is numeric and just jumps x lines if true and y lines if false. If you subsequently insert extra code lines later and forget to adjust your Jump, thingfs will fall apart. While the Goto Label takes a bit more work, it is more robust.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 19 2009 at 15:43 | IP Logged
|
|
|
GadgetGuy wrote:
Sorry to be confusing. That's not much help for you!
Since I didn't know what your Tab names was (but looking at your image captures now, I see it) I didn't want to confuse you by using your names but in the wrong way.
Taking the example from the forum that you used as a prototype (repeated here for clarity)...
LIGHT1
Light1 Status Change
Raw Formula
ph_setccobjbcolor("CC_TAB_ID_OF_BUTTON","CC_BUTTON_ID_OF_LIG HT",case([LOCAL10] when 0 then 8421504 else 65535))
Enabled
Insteon Device Chg
ID_OF_LIGHT
1
(Any)
1
We would have for the object color line (using your names):
ph_setccobjbcolor("MASTERBEDROOMLIGHT","GB1N",case(TEST_VAR_NEEDED_HERE when 0 then 8421504 else 65535))
You are OK with most of your entry but you are missing the variable to be tested for a zero value. |
|
|
Ken
Much clearer now but what is TEST_VAR_NEEDED_HERE? Is it a variable associated with the button? Or is it something else?
Thanks
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: January 19 2009 at 16:10 | IP Logged
|
|
|
Yes to both questions!
That is, it is whatever you want to sense the state of and then change. For example from my buttons I set off a macro (the ph_macroparm("TOG-SWITCH",.. in the CC Object properties window image several Replies above)that examines the state of the associated light using the ph_insteonlevel() command and then toggle the light into the opposite state (ie... If 1 then make it 0, else 1 [that's not a real command just a description of what is done]. That maco then calls a macro that waits 2 seconds (for the light change to take effect) and then reads the state of the light and sets the graphic associated with the button {ph_setccobjgraphic ( tabid, id, upfile, downfile, flags ) }to be red/green; yellow/black whatever you want to associate with the on and off states of the light.
I'm trying to stay general here, as there are so many ways to do this. Once I get to a reasonably fonished state I'm thinking of posting my code to the Repository in the Forum so others can see examples. Hopefully that is only a week or two off.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 19 2009 at 18:52 | IP Logged
|
|
|
OK I still need alittle more help. I'm trying to figure out which variable to use. Would it be off the control center or an insteon device? Or do I need to declare a variable? Let's use the following example.
The following photos show the two areas I have been looking at for possible variables (using the on button):
Should I use GB1N or INSTEON+MBLIGHT+ON? Or MBLIGHT (which is the insteon device ID) or something else?
Also the button is already setup for certain images that display whenever the light is turned on/off. Will this new macro overwrite the existing images?
Thanks
Edited by williammanda - January 19 2009 at 18:55
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: January 19 2009 at 19:44 | IP Logged
|
|
|
William - It is a little difficult to fully answer your question as I can only guess what you are trying to do, since it is so far unstated.
It appears that you want to turn your bedroom light on or off with the two buttons.
If that is the case then your Device Control string entered in your Action Tab for the On button (I assume) appears correct and fully sufficient to turn the light ON. A similar Action Button for the off control would be the same but construcrted "INSTEON+MBLIGHT+OFF"
If this is all you want to do with these buttons then you are done. You don't need a macro. The Up/Down graphics you set up in the Control Center Object Properties just control how the button looks in its default (up) state when nothing is happening to it, and what the image is when you press the button (the Down graphic). The Down graphic only lasts for less than a second to give you visual feedback the button has been pressed. Then the graphic goes back to the Up graphic.
If you want something different then you need to create a macro to manage the graphics, and yes that will replace the Properties window graphics settings.
In summary, you don't need to use your case function at all if you are happy with just button presses causing actions but without graphic synchronization to the actual light state.
If you want to change the graphics then your case statement has to be more than a color change as you had it. That only works when you have a simple rectangle that you change the background color for. To change a graphic button's color you need to select a different ggraphic.
Here is an example using your names ...
Code:
if(ph_getinsteonlevel("MBLIGHT")=0,ph_setccobjgraphic("MASTE RBEDROOMLIGHT","GB1N"]","C:\Program Files\powerhome\web\graphics\buttons\b1gray-d_75.gif",""),ph _setccobjgraphic("MASTERBEDROOMLIGHT","GB1N","C:\Program Files\powerhome\web\graphics\buttons\b1green-d_75.gif","")) |
|
|
In this macro you are testing the state of MBLIGHT to see if it is off or on and setting the graphic image to gray or green. (Hopefully I have the macro written correctly. I didn't test it so take it with a grain of salt!)
Hope this helps more.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
williammanda Groupie
Joined: December 03 2008 Location: United States
Online Status: Offline Posts: 84
|
Posted: January 19 2009 at 20:30 | IP Logged
|
|
|
GadgetGuy wrote:
William - It is a little difficult to fully answer your question as I can only guess what you are trying to do, since it is so far unstated. |
|
|
I want the Control Center screen to reflect the status of the light it is controlling by either a color change, graphics change or text. This has been my sole purpose throughout this post. I found this entry in the forums while searching for a way to create additional items in the control center but that it off topic.
Quote:
It appears that you want to turn your bedroom light on or off with the two buttons.
If that is the case then your Device Control string entered in your Action Tab for the On button (I assume) appears correct and fully sufficient to turn the light ON. A similar Action Button for the off control would be the same but construcrted "INSTEON+MBLIGHT+OFF"
If this is all you want to do with these buttons then you are done. You don't need a macro. The Up/Down graphics you set up in the Control Center Object Properties just control how the button looks in its default (up) state when nothing is happening to it, and what the image is when you press the button (the Down graphic). The Down graphic only lasts for less than a second to give you visual feedback the button has been pressed. Then the graphic goes back to the Up graphic. |
|
|
This out of the scope of the topic and I have a working grasp of it.
Quote:
If you want something different then you need to create a macro to manage the graphics, and yes that will replace the Properties window graphics settings.
In summary, you don't need to use your case function at all if you are happy with just button presses causing actions but without graphic synchronization to the actual light state. |
|
|
Again not on topic.
Quote:
If you want to change the graphics then your case statement has to be more than a color change as you had it. That only works when you have a simple rectangle that you change the background color for. To change a graphic button's color you need to select a different ggraphic.
Here is an example using your names ...
Code:
if(ph_getinsteonlevel("MBLIGHT")=0,ph_setccobjgraphic("MASTE RBEDROOMLIGHT","GB1N"]","C:\Program Files\p owerhome\web\graphics\buttons\b1gray-d_75.gif",""),ph _setccobjgraphic("MASTERBEDROOMLIGHT","GB1N","C:\Program Files\powerhome\web\graphics\buttons\b1green-d_75.gif","")) |
|
|
In this macro you are testing the state of MBLIGHT to see if it is off or on and setting the graphic image to gray or green. (Hopefully I have the macro written correctly. I didn't test it so take it with a grain of salt!) |
|
|
Great! This is what I'm after.
Thank you
|
Back to Top |
|
|
tbeckman Senior Member
Joined: December 30 2007 Location: United States
Online Status: Offline Posts: 149
|
Posted: February 04 2009 at 21:49 | IP Logged
|
|
|
Just checking back... has automated support for checking the light status in the CC been implemented? Thanks.
|
Back to Top |
|
|
syonker Senior Member
Joined: March 06 2009 Location: United States
Online Status: Offline Posts: 212
|
Posted: February 09 2012 at 11:20 | IP Logged
|
|
|
Ok, picking up an old thread here....so with this case statement, all of these examples have been "CASE(WHEN condition THEN blah1 ELSE blah1)". Doesn't that basically do the same thing as an "if(condition, blah1, blah2)"...?
What I need to do is check an incoming ph_macroparm() parameter to see if it's *either* one of two strings, or leave it alone...hence I have a "Set Global" line in a macro with something like this in the Forumula:
case ( ph_getvar_s(1,3) when "FAN_AUTO" then {HVAC_SP} when "FAN_ON" then {HVAC_SP} else ph_getvar_s(1,3) )
So.....why the SYNTAX ERROR? Does case() only support a bi-polar logic outcome (THEN and ELSE)?
-S
__________________ "I will consider myself having succeeded when my house becomes sentient and attempts to kill me."
><(((º>`·.¸¸.·´¯`·.¸><(((º>¸.
·´¯`·.¸. , . ><(((º>`·.¸¸.·´¯`·.¸><(((º>
|
Back to Top |
|
|
GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: February 09 2012 at 11:24 | IP Logged
|
|
|
Syonker -
It happens to me all the time. Got caught by the same issue just last week.
Case cannot accommodate mixed variable types such as numbers and strings.
Surround your Global vars with quotes to make everything a string.
Thus "{HVAC_SP}"
That should do it.
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|
Back to Top |
|
|
syonker Senior Member
Joined: March 06 2009 Location: United States
Online Status: Offline Posts: 212
|
Posted: February 09 2012 at 11:50 | IP Logged
|
|
|
Ah yes, that makes sense. The if() also has this restriction if memory serves.
Thanks Dave!
-S
__________________ "I will consider myself having succeeded when my house becomes sentient and attempts to kill me."
><(((º>`·.¸¸.·´¯`·.¸><(((º>¸.
·´¯`·.¸. , . ><(((º>`·.¸¸.·´¯`·.¸><(((º>
|
Back to Top |
|
|