Author |
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: June 18 2009 at 23:08 | IP Logged
|
|
|
I know this is an old subject, however, I seem to not be able to find an answer.
"How can one programmatically determine a KPL button status?".
I see the PH.GetInsteonLevelRT(id) function. That looks like the answer for non-KPL devices.
Will the PH.GetInsteonLevelRT(id) function supply only the KPL button 1 status?
What about buttons 2-8?
Do the PowerHome "status" checkboxes have to be set in a specific manner to have this/or any function work?
I am considering building triggers with global variables that mimmick the button status, but would rather be able to query directly.
Thank you in advance,
Richard
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: June 18 2009 at 23:50 | IP Logged
|
|
|
Same question came up on another forum a few days ago. Issue a cmd1 0x19 cmd2 0x01. The cmd2 response is a bit map that represents each KPL button.
__________________ Lee G
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: June 19 2009 at 00:14 | IP Logged
|
|
|
I have seen mention of this type of command, but am a newbie to using it.
Would it look like this:
rv = ph.insteonwithret( "KPLKitchen", 0x19, 0x01 )
rv would contain the bitmap of the status of the KPLKitchen KPL buttons?
If you have an example that would be great!
Thank you for the help,
Richard
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: June 19 2009 at 00:59 | IP Logged
|
|
|
You have the command correct. Use decimal values for cmd1 and cmd2. The first example stores the returned value in a Global variable GVLOCALRESULT. The second example uses the ph_and function to isolate a specific bit in the returned value to see if that bit is on. Because the value returned is the total numeric value of all the bits that are on, it is necessary to isolate a specific bit and test the result rather than checking for an absolute numeric value. To test the right most bit use 1 in the ph_and, to test the left most bit use 128 in the ph_and. If the result of the ph_and is zero (0) the bit tested is not on.
ph_setglobal_a ( "GVLOCALRESULT", ph_insteonwithret("TABLE KEYPAD", 25, 1))
ph_and(ph_getglobal_n("GVLOCALRESULT"),1) to test the right most bit
ph_and(ph_getglobal_n("GVLOCALRESULT"),128) to test the left most bit
__________________ Lee G
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: June 19 2009 at 09:41 | IP Logged
|
|
|
Perfect. Let me put this into action and I'll post how things go.
Thank you for the invaluable help!
Richard
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: August 04 2009 at 23:30 | IP Logged
|
|
|
I'm back from a slight hiatus from Home Automation.
I used Lee's direction to setup a VBS program to obtain KPL status, put it into production, and it works fine. Thank you Lee!
I have attached a complete VBS that I expanded upon as an example that shows how to find the status of any of the 8 KPL buttons.
Note that in the code, the CLng (convert to a Long) function is embedded in the "PH.BitAnd" function. This is necessary to make the variable vntKPLMask a long. Variables in PH functions use a long, VBS by default uses a variant - so the variable must be converted. The converstion must happen in the function itself, not defined before.
Happy coding!
Richard
2009-08-04_232848_KPLStatus-Test.zip
|
Back to Top |
|
|