Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: How to most reliably detect a keypress? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 23 2010 at 15:48 | IP Logged Quote jeffw_00

You would think this would be simpler...

I have several Controllinc's and KPLs in the house. After a long period of trial/error, I finally wrote common PH code that would detect -either- the Broadcast message -or- the Cleanup message, but not both. This gives me very reliable operation because it's very very rare that both messages don't get detected. However, it's not at all rare that one message, or the other, isn't detected.

So I have code that, if it detects the broadcast, ignores the cleanup, or alternately, if the cleanup is the first thing it sees, it acts on it.

Still, I've always wondering if this is what SL intended, or whether there's a more straightforward way to most reliably detect a keypress (which seems pretty important).

any thoughts?

thanks
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: March 23 2010 at 20:39 | IP Logged Quote grif091

The Group Broadcast is not retried so missing that one is possible but unusual. Missing the Group Cleanup Direct is so unusual to suggest that something is very wrong with powerline communication or the PLM as the KPL/Controlinc will resend the Group Cleanup Direct until the PLM ACKs it. There is a max 3 retry attempts but if a total of 5 commands do not work there is a very significant problem.

Edited by grif091 - March 23 2010 at 20:42


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 23 2010 at 21:00 | IP Logged Quote jeffw_00

missing the cleanup is rare, much more rare than missing the broadcast, but not unheard of in this house. I suppose I could go looking for the problem, but on the other hand, my "either-or" seems to be pretty darn rock solid.

I don't see the retry attempts you mention, and if I remember correctly, I don't think keypad presses are hand-shaked, which is why this issue occurs. How sure are you that the KPL looks for an ACK of the cleanup?
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: March 23 2010 at 21:17 | IP Logged Quote grif091

You will not see the retry process in the PH log as that is all between the PLM as a Responder and the KPL/ControLinc as a Controller. My KPL buttons actually blink when the responder fails to ACK. There is a post on the Smarthome forum that indicates the newest KPL buttons no longer blink when doing retries. You can usually watch the retry activity with a PLC that is being monitored by some other piece of software. I keep hoping that Smartlabs will develop an independent powerline Insteon message monitor something like the Monterey Signal Analyzer for X10 but for now the only way I know of is to use one of the old PLCs. It is not absolute but better than nothing.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 23 2010 at 21:20 | IP Logged Quote jeffw_00

my buttons blink when the controller is out to lunch as well, but even when they don't, I saw better reliability when I put the 'either or' in place.
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: March 24 2010 at 15:04 | IP Logged Quote MrGibbage

I also find detecting keypresses inconsistent. I have
rewritten the code for detecting my CL presses, that I
don't remember what I have tried and what I have not. I
would be interested in seeing your code, if you would be
willing to share.
Bottom line is I do not see the detection of keypresses
reliable at all. I think it is pretty important to all
this HA stuff, and I really wish it was more reliable.
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: March 24 2010 at 15:21 | IP Logged Quote dhoward

Another point I want to add to Lee's post is that the group cleanup command (the direct, ACKed command following the group broadcast) is not a guaranteed command and may never actually be sent. The Insteon protocol has the group broadcast sent when a button is pressed (unACKed and not retried) followed by the group cleanup command direct to each responder UNLESS another Insteon traffic takes place in which the group cleanup sequence is aborted. So if you've got other traffic occurring when you press a button, its likely you will ONLY get the group broadcast which is not as reliable as the group cleanups. Ive always thought this was a troublesome aspect of the protocol.

With that aside though, probably the best way to track a button press (unfortunately wont work until the beta is released) will be to add a Virtual Insteon device as a responder to the button and then setup an Insteon Device Chg trigger on the virtual device. This will allow you to have a single trigger to monitor the button press as well as allow you details into what was the actual command (broadcast/cleanup/etc) that caused the Device change.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 24 2010 at 15:54 | IP Logged Quote jeffw_00

Dave's first paragraph jives with my memory. How they could make everything else so handshaked and leave out keypresses still astounds me.

Dave - as for your 2nd paragraph - Probably my lack of understanding, but I don't see how that helps. I already use a trigger on Insteon Device Chg to detect the keypress. All keypresses go to the same macro (with one LOCAL passed to differentiate which key was pressed), and the first thing the macro does is the XOR on the broadcast vs. cleanup msg before calling a macro to execute the desired command.

How does your Virtual device reduce my code? (I can wait for the Beta doc to learn the answer if you prefer).

I'll post my code tonight or tomorrow night.

/j

Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: March 24 2010 at 17:07 | IP Logged Quote dhoward

Jeff,

I must have misunderstood. I was thinking that you had a couple of triggers...one for the group broadcast and one for the group cleanup. If you're already using Device Chg then you're good and wouldnt need the Virtual Insteon device (you must already have a real physical device that you're using for the Insteon Device Chg).

The virtual Insteon would be good for those situations where you don't want to actually link a physical Insteon device (other than the PLC...got to do that in order for a message to be generated) to a secondary KPL button or similar and want to fire triggers off of the secondary key presses. An example of how I do this is to have secondary KPL buttons with no physical devices linked to fire triggers in PowerHome to remotely change my Russound whole house audio controllers music source. A completely un-insteon action all controlled via Insteon .

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 24 2010 at 17:15 | IP Logged Quote jeffw_00

Hi Dave - I don't have the code in front of me, but I found the most reliable approach was to trigger off any change, and then decode -which- change in the macro and act accordingly.

Maybe not worth responding, but I lost you - not sure what you mean by "secondary KPL buttons with no physical devices".

anyway - I guess with the hole in the protocol the XOR is the way to go - i'll post the code soon
/j
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: March 25 2010 at 11:41 | IP Logged Quote MrGibbage

Is this virtual insteon switch in response to this:
http://www.power-home.com/forum/forum_posts.asp?TID=1276

If so, cool! :) I think that will solve the problem, and
will be a very powerful feature.

Dave, when you get a chance, can you post an
example/tutorial of how we will set it up, and then use
it? Maybe include a screenshot of any applicable
screens?

Skip

Edited by MrGibbage - March 25 2010 at 11:42
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 25 2010 at 19:53 | IP Logged Quote jeffw_00

Ok, my code is below. Basically it looks to see if it got a broadcast or a cleanup, if it gets a broadcast, it sets a global for about 1 second, and then executes the macro. If it gets a cleanup, it checks the global, and exits if the global is set, otherwise it executes the macro.   I usually disable most of the user messages.

the CLEANUP counter (detects Broadcast without cleanup) currently reads 40, and I haven't cleared it in months.

HTH
/j



KEYPRESS      1      COMMENT      getvar_n(2,4) = 5 means broadcast, 6 means cleanup
KEYPRESS      2      GOTO LABEL     if(ph_getvar_n(2,4)=5,"NE XTLINE","CHECK_FOR_CLEANUP")
KEYPRESS      3      USER MESSAGE      "BROADCAST_DETECTED, KEYPAD: [LOCAL1] key: [LOCAL2]"
KEYPRESS      4      FORMULA      ph_macroparm("DOBROADCAST",ph_ getvar_s(1,1),ph_getvar_s(1,2),0,0,0)
KEYPRESS      5      GOTO LABEL     "START"
KEYPRESS      6      LABEL    & nbsp;     CHECK_FOR_CLEANUP
KEYPRESS      7      GOTO LABEL     if(ph_getvar_n(2,4)=6,"NE XTLINE","DONE")
KEYPRESS      8      USER MESSAGE     "BROADCAST = {BDCST}"      
KEYPRESS      9      GOTO LABEL     if ({BDCST}=1,"NEXTLINE","CLEANUP_START")
KEYPRESS      10      SET GLOBAL      BDCST            0      
KEYPRESS      11      FORMULA     ;         ph_killmacrowait("DOBROADCAST")      ;  
KEYPRESS      12      USER MESSAGE     "CLEANUP DETECTED AFTER BROADCAST, KEYPAD: [LOCAL1] key: [LOCAL2], ABORTING"
KEYPRESS      13      GOTO LABEL     "DONE"           
KEYPRESS      14      LABEL    & nbsp;     CLEANUP_START
KEYPRESS      15      USER MESSAGE      "CLEANUP DETECTED, KEYPAD: [LOCAL1] key: [LOCAL2]"
KEYPRESS      16      LABEL    & nbsp;     START


DOBROADCAST      1      FORMULA     ;       ph_killmacrowait("DOBROADCAST" )
DOBROADCAST      2      SET GLOBAL     BDCST            1
DOBROADCAST      3      WAIT            1
DOBROADCAST      4      JUMP    &n bsp;     if({BDCST}=0,999,1)
DOBROADCAST      5      SET GLOBAL      BDCST            0
DOBROADCAST      6      SET GLOBAL      CLEANUP      ph_addtoglobal("CLEANUP",1)
DOBROADCAST      7      FORMULA      ph_setvar_s(1,8,string(today() ,"yyyy-mm-dd hh:mm:ss.fff"))
DOBROADCAST      8      FORMULA      ph_setvar_s(1,7,"[LOCAL8]: BROADCAST, BUT NO CLEANUP, RECEIVED. KEYPAD: [LOCAL1], key [LOCAL2] " + char(13) + char(10))      0      
DOBROADCAST      9      FORMULA     ;      ph_writefile("c:\jeff\insteon\error.log",0,ph_getvar_s(1,7))

Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 25 2010 at 19:59 | IP Logged Quote jeffw_00

ps - could someone remind me the right way to export a single macro? 8-}
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: March 25 2010 at 23:02 | IP Logged Quote grif091

Using Powerhome Explorer, with the list of Marcos displayed in the right pane, right click on the macro you want to export. A list of functions is displayed with Export being one of them.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
jeffw_00
Super User
Super User


Joined: June 30 2007
Online Status: Offline
Posts: 929
Posted: March 26 2010 at 10:42 | IP Logged Quote jeffw_00

thx
Back to Top View jeffw_00's Profile Search for other posts by jeffw_00
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum