Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Multi-X Commands Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 09 2002 at 01:06 | IP Logged Quote hollis

I read the manual which gave background info on using the Multi-X commands, but did not give specifics on how to get this to work. Could you please elaborate? This looks like a very handy feature!
Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 09 2002 at 18:19 | IP Logged Quote dhoward

Look for improvements to the multi-x in an upcoming release including multi-x tracking by housecode, a bigger multi-x stack, and formulas to make the use easier. Currently the multi-x is implemented as system variables that keep track of incoming X-10 commands. Also, certain X-10 house/unit codes can be excluded from the multi-x stack. The last piece that controls the multi-x is the previous incoming X-10 timeout setting. The system variables are [X10P0] thru [X10P5] with X10P0 being the most recent incoming command. You can exclude units from within the Explorer in the X-10 Unit Codes screen. The previous incoming timeout setting is in the Explorer under Setup on the X-10 Setup screen.

When you want to have an action based upon multiple incoming X-10 commands, you'll want to check the system variables. The format of the data within the variable is in the form of housecode, unitcode, command. K7 on would appear as K0702. If you wanted to perform an action based upon two incoming X-10 commands say K5 on followed by K8 off, then you could easily check this condition with the following if statement:

if("[X10P0][X10P1]" = "K0502K0803",perform action,else no action).

In the sample database, you can see how Im using multi-x in the PP K ALL macro. Its difficult to explain, but if you have any further questions, just let me know.

Dave.

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 10 2002 at 11:25 | IP Logged Quote hollis

Thanks a million. That helped a lot. But I ended up taking a different approach than your example. There were a lot of triggers and a lot of macros. I used one trigger and one short macro to accomplish Multi-X. I also "sacraficed" half of the possible key combinations for a method that greatly simplifies associating a particular result to the keys pushed. (I needed to do something here since my wife also needs to use the remotes and memorizing the resulting action of 256 key combinations ain't an option!).

The first key pushed will determine the housecode and action (off or on). The second key will determine the unit code. The remote can be used for normal functionality when set on "1-8" and is in multi-x mode when set to "9-16" of one of the housecodes. Multiple housecodes could be multi-x'ed also but will require one additonal trigger per housecode. The row number of the first key pressed determines the housecode of the multi-x command. Any key in row 1 = housecode A, row 2 = B, etc. (up to max H). If chosen from the "ON" column, then the multi-x will execute the "ON" action. If "OFF" column, then "OFF" action. The second key determines the unit code of the command. Keys 1-8 ON = unitcodes 1-8. Keys 1-8 OFF = unitcodes 9-16.

I chose housecode "B" since I have 8 commonly used (via remote) units on this code. So having the remote set to 9-16 and pushing from row 3 column "On" (3/On) followed by 4/ON would result in tuurning on the device set to housecode C (3=C) unitcode 4. Pressing row 2 "ON" followed by 1 "OFF" would turn ON device B9. To turn off B9, press row 2 "OFF" then 1 "OFF".


Here's how I did it. I set the trigger to run my multi-x macro for B/Any/Addressed. The macro determines if there was a single or multiple key sequence. If single, exit macro. If multiple keys and unitcodes >8 (remote in 9-16 mode), evaluate the {x10+...} sendkey command and execute. Another bit of code is also needed so that the command is only executed once since the macro will run twice for a two-key sequence.

I'm also going to modify the code so that I can always leave the remotes in the 9-16 position. If a single key sequence is detected, the corresponde 1-8 unitcode will be executed (e.g. B10/Off will send the command to execute B2/Off) so there will be no need to click back and forth from the 1-8 to 9-16 mode (another potential source of confusion and frustration for the non-engineers in my family ).

I'll send a snapshot of the code once I finalize and polish it up a bit.
Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 11 2002 at 07:42 | IP Logged Quote dhoward

Excellent! Ive been meaning to rewrite my multi-x macros to take advantage of the new triggers but just havent found the time yet. Im glad that you got it all figured out and that its working for you. Once you get it polished, I would love to see it and if you're interested, I'll post it on the board so others can learn.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 11 2002 at 23:19 | IP Logged Quote hollis

I have it working well. The only drawbacks are that it can take up to three or four seconds sometimes before a Multi-X function actually performs the action (and I don't see much room to speed up the macro - but am open to ideas to improve the response time) and I can't put my computer in sleep mode (except at night maybe) since this adds significantly to the delay. But it is really cool and one huge advantage is that I can have a minimal amount of transceivers (only one for small house) set to the housecode I have triggered for Multi-X, but can use all of the housecodes for the X-10 devices. It appears as though you use the RemoteMouse, so this may not be a big plus for you, but it is for others (me in particular)! I have a big house and want to use lots of house codes. I need two to three transceivers per housecode if I want to be able to use a remote or motion detector anywhere in the house to activate. This adds up quickly!

I'm also going to develop a way of allowing me to use my slimpad and keychain remotes for multiple functions. I could use my current macro if I use the proper housecodes and unitcodes for devices I want to control for the pad, but it would probably be better to come up with a new approach for this. I'll let you know what I come up with.

I'll place a link to a txt file with comments of my current version of the Multi-X macro in a following post (I need to write the .txt file first though! )

Once again, thanks for the great program and the great help!
Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 12 2002 at 03:31 | IP Logged Quote hollis

OK. Here's the code with explanations and comments. I'm looking forward for some suggested improvements!
-------------------------------------------------------
Multi-X macro

Use: Assumes a mulitpe sequence (two) of keystrokes on a full size remote (e.g. HR12A) set to the "9-16" setting on a housecode selected for Multi-X. A trigger must be set for the housecode (or housecodes) that you want to work as Multi-X.   (Trigger on that housecode, ANY unitcode and ADDRESSED).

I also added a couple of lines to the macro so that single keystrokes are interpreted as if the remote keypad was set to "1-8". The reason for this is that no devices (or macro triggers) should use unitcodes 9-16 since they would be activated multiple times when using the keypad for Multi-X sequences. So I might as well interpret single keystrokes as if the user thought the keypad was set to "1-8". This also makes life simplier for all (no need to switch back and forth from 9-16 and 1-8 or for cases when you assume the keypad is set to 1-8 and you get frustrated after pushing the key several times with nothing happening!).

In the following, I use the nominclature of "rows" to refer to the keys 1-8 (either ON or OFF) and the columns as the "ON" column and "OFF" column. So the "ON" key from the first row of the keypad is refered to as 1/ON. The "OFF" key from the last row is 8/OFF.

I decided to interpret the keystrokes as follows:

1st key: determines the unitcode and function (ON/OFF) as you normally would select in "standard mode".

2nd key: determines the housecode and 1-8 or 9-16. Row 1 is housecode A, row 2 is B,..., row 8 is H and keys from the "OFF" column will add 8 ("9-16" mode) to the row of the first key ("ON" adds 0 = "1-8" mode).

Example 1: Key 6/ON is pressed followed by 2/ON (within the Previous Incoming Timeout limit). This will result in 6/ON (first key) for housecode B (row 2 for 2nd key).

Example 2: Key 3/OFF then 2/OFF = B11 (add 8 to row of 1st key since OFF for second key) OFF (since OFF for 1st key).
Example 3: 4/OFF,7/ON = G4 OFF.
Example 4: 1/ON, 2/OFF = B9 ON.

I tried various approaches here, and this one ended up being the most "natural". The first key is the normal way you would use the keypad remote. You need to think a little on the second, but with proper labeling and grouping of similar units on the same housecodes, it's pretty simple.

I label the rows of the keypad with the housecode and pnuemonic that refers to the functionality of that housecode group and the "9-16" unitcodes in the top left. For example, I have all units on the outside of the house on housecode C. So row 3, I have small text that says:
   11
    C Outside
Afer a couple of times of using it, it comes pretty easy. The real challenge though will be to see if my wife finds it easy or not. She has a small tolerance for anything inconvenient, so if I pass her approval, I'll know I have succeeded!

For a correct 2-key sequence, a total of 6 lines of code are run. I use Jumps where there is little danger of causing problems (if I go back and edit the code or add User Messages) to try to cut back every milisecond of response time. (Boy, this reminds me of my microprocessor days programming in Assembly having to cut-back every byte possible!)

Here's the code with comments:
------------------------------

10 Goto Label:     if("[X10P1]"="00000","next","MultiX")     : Check to see if multi key sequence or not
(I save a line of code since there is no "next" label and the program sequence follows with this line if not "MultiX".
The following code handles single key sequences. It exits if unitcode is 1-8 or if >8, subtracts 8 from the unit code and executes the command corresponding to the housecode and function of the key pressed.)
20 Set System [MACRO2]     integer(mid("[X10P0]",2,2))-8
30 Jump          if([MACRO2]>0,1,999)
40 Set System [MACRO1]     mid("[X10P0]",1,1)     :get housecode
50 SendKeys Formula Immediate     "{x10+[MACRO1]+[MACRO2]+0}{x10+[MACRO1]+1" + mid("[X10P0]",4,2) + "+0}"
70 Jump 999

80 Label MultiX (multiple key sequence detected)
(Since a multiple key sequence results in multiple triggers, you need to make sure you execute the command only for the first trigger and ignore for the rest. I'm opened for suggestions for improvements here, but here's what came to mind for me. I define a global variable and set it to the current time initally. This value is set to now() by the macro right after executing the Mult-X command. The macro will check if the current time is less than 2 seconds (my setting for Previous Key Timeout). If so, the macro assumes this is a redundant trigger and exits the macro without performing any action. One other thing is needed here for a new day. I already have a trigger set for midnight to trim the log, so I added a line to set my Multi-X global variable to now() when this is run. This isn't pretty, but it seems to work fine so far.)

90 Jump     if(secondsafter(time("{MULTI-X-LASTRUN}"),now())>2,1,999)

(So now it's time to process the Multi-X key sequence. The first question to address is how to handle if a multi key sequence of greater than 2 keys are detected? I needed to overcome a big problem here. I have a big house, so I need multiple transceivers on the same housecode to be able to use the remotes and motion detectors throughout the house. But when 2 transceivers receive the signal from the remote, the normal result is that either the first or second key will be interpreted twice. So throwing out the duplicate command results in fairly high reliability. For Multi-X commands >3 keys, I assume the first two keys pressed are the Multi-X sequence. You could easily modify the code below to allow even more functions to be performed for 3 keys or 4 keys or more in a row. For instance, I might have this run a special macro that defines things like "if 1/ON is pressed 3 times in a row, turn all lights on; or 1/OFF 3 times executes all lights off. Just add a line to run the special 3 key sequence in the 3keys section below.

100 Set System [MACRO1]     "[X10P1][X10P0]"     :string containing key1 and key two
(For example, a key sequence of 13/ON, 14/OFF with the Multi-X housecode trigger for B would result in B1302B1403. Note also that I make this macro generic to handle any housecode. So enable other housecodes to be Multi-X, just add the trigger for that housecode as described above and this macro will work.)

110 Goto Label     if("[X10P2]"="00000","Continue","next")
120 Set System [MACRO1]     if("[X10P2]"="[X10P1]", "[X10P1][X10P0]", "[X10P2][X10P1]")

130 Goto Label     if("[X10P3]"="00000","Continue","next")
140 Set System [MACRO1]     "[X10P3][X10P2]"

150 Goto Label     if("[X10P4]"="00000","Continue","next")
160 Set System [MACRO1]     "[X10P4][X10P3]"

170 Goto Label     if("[X10P5]"="00000","Continue","next")
190 Set System [MACRO1]     "[X10P5][X10P4]"

200 Label "Continue"
(Now convert the string of the two keycodes to the proper SendKeys format to execute.)
210 Set System [MACR02]          case(mid("[MACRO1]",7,2) when "09" then "A" when "10" then "B" when "11" then "C" when "12" then "D" when "13" then "E" when "14" then "F" when "15" then "G" when "16" then "H" else "1to8")     :The row of the second key determines housecode

(We should ignore multi-key sequences if the keypad remote is set to "1to8")
220 Jump if("[MACRO2]"="1to8",999,1)
(Determine unitcode)
230 Set System [MACRO3]     integer(mid("[MACRO1]",2,2)) - if(mid("[MACRO1]",9,2)="02",8,0)

(I added this line since sometimes I got invalid commands that resulted from multiple transceivers sending the signal to the CM11A almost simultaneously which resulted in crashing PowerHome. I kept it simple since everytime the crash resulted from having a unitcode of 0, but I will add more if I observe other crashes.)
240 Jump     if([MACRO3]>0,1,999)

(Now, for the grand finale!)

220 Send Keys     Formula Immediate     "{x10+[MACRO2]+" + [MACRO3] + "+0}{x10+[MACRO2]+1" + mid("[MACRO1]",4,2) + "+0}"

230 Set Global {MULTI-X-LASTRUN}     now()     :need this to prevent redundant executions (see above)
Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 15 2002 at 11:14 | IP Logged Quote dhoward

Hollis,

The code looks great! I posted some comments about it under your message in the bugs forum. I'll be doing some testing this weekend and see if I can speed up the response time.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 15 2002 at 15:31 | IP Logged Quote hollis

I copied your response from the Bug Report section to continue the thread here. You wrote:
------------------ Begin Quote ------------------------
Now about your multi-X macro...Ive been looking over your code and it looks great! However, there could be some problems. Your trigger is on Any unit addressed. The problem is that the multi-X variables are only updated after an on,off,dim, or bright command is received. Normally, when using a palm pad, this will be immediatly following the address command, but I see the potential for timing problems. The addressed trigger will fire immediately after the address comes in. The internal flags within PowerHome will be updated to show that the unit has been addressed. When the corresponding on,off, etc command is received, the trigger for the any on,off,etc. is executed. Then the multi-X variables are updated. Then the trigger for the specific on,off,etc. is executed. I would think that you would get more consistent results by defining a trigger for the on and off for each unit within that housecode. I know that its a lot more triggers, but it wont affect the speed any since PowerHome will query the database for the specific trigger and only 1 will be checked and returned from the 16. I will be documenting the chain of events for X-10 receives and updating the manual. The other thing that I couldnt really understand was how you could leave the switch on 9-16 and differentiate between a single command intended to control 1-8 and the start of a multi-x command. If the prev incoming timeout was exceeded, then the [X10P1] variable will be "00000". The next command that comes in, how can you tell if it was intended to be a single command to control 1-8 or the first command of a multi-x command? Concerning the response time...3 to 4 seconds is way excessive. I actually get almost better response time pressing two buttons for multi-x rather than 1 because my CM11A seems to buffer and wait for a moment when it receives just 1 command but requests to be serviced immediately when two or more commands are received. Im using the mouseremote now, but when I was using transceivers, I got just over a second in response time on a two-key multi-x. I'll try to input your code and play with it and see if I can improve the response time at all.
------------------ End Quote -------------------------

I'll add a new post with my response.
Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 15 2002 at 15:49 | IP Logged Quote hollis

Thanks again, Dave.
I don't completely understand why the trigger no Any/Addressed is problematic. It seems to work fine except the issues of response time and the crashing as described in the Bug Report posting. But these don't seem to be related to this.

I like just using one trigger on Any/Addressed since it makes it very easy to add or substract a housecode to be Multi-X enabled. I just add one additional trigger for that housecode to run the Multi-X macro and I'm there. But, as mentioned previously, others in the house using this won't be very tolerant to hicups, so I may change to prevent any issues.

How about this for a compromise? I just add ON and OFF triggers for the corresponding keys use to designate housecodes? This way, the macro will only be run once (desireable) in most cases and many fewer triggers.

So, for example, I currently use housecodes B, C and H in my house. So I set triggers for 10/ON, 10/OFF, 11/ON, 11/OFF, 16/ON and 16/OFF on the Multi-x enabled housecode(s). I tried it and it seems to work great.

---------------------------------
Now to reponse to your question regarding "how you could leave the switch on 9-16 and differentiate between a single command intended to control 1-8 and the start of a multi-x command."

I assume that the 9-16 unitcodes for the Multi-X enabled housecode ARE NOT USED. So a single command with unitcode 9-16 is translated as the same command for the (unitcode - 8) unit from the Multi-X enabled housecode.

So the way this works is that the most common devices are placed on units 1-8 of the Multi-X enabled housecode and the remote is placed in the "9-16" position. Press a one-key sequence to simulate the remote being in the 1-8 postion, or execute a multiple key sequence to turn on/off any other unitcode/housecode device.

The only issue here is the problem mentioned with the multiple transceivers which will sometimes send multiple signals to the CM11A which is interpreted as a multiple key sequence. But this won't be a problem for users who have only a single transceiver (or use only the MouseRemote like yourself).


Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
hollis
Groupie
Groupie


Joined: February 09 2002
Location: United States
Online Status: Offline
Posts: 28
Posted: February 17 2002 at 01:57 | IP Logged Quote hollis

Since I have several keychain remotes (KR19A - only 2 devices controlled in standard mode), I came up with a scheme for Multi-X'ing them for 8 devices.

- Housecode will be whatever housecode is set for the SlimPad.
- The SlimPad is set to control devices 15 and 16 of the defined housecode. (These unitcodes should not be used for any real devices).
- 1st key in 2-key sequence: determines ON/OFF function (ON=ON, OFF=OFF) and unitcode offset (row 1 = +0, row 2 = +4).
- 2nd key: determines unitcode base (row 1/ON=2, 1/OFF=2, 2/ON=3, 2/OFF=4). The unitcode will be this number plus the offset from the first key.

So the key sequence row 1/ON,row 2/OFF = unit 4/OFF.
2/ON,1/OFF=unit 6/ON.
2/OFF,1/ON=unit 5/OFF.
1/ON,1/OFF=unit 2/ON.

Sounds difficult, but is actually pretty easy for me to use.

The code is pretty much the same as Multi-X for PalmPad, except the converting 2-key multi-X string to x10 Send Keys would look like:

[MACRO1]=string containing "[X10P1][X10P0]" of Mulit-X command (note I did same trick as above to handle situations where PowerHome interprets more than a 2-key Multi-X sequence).

[MACRO2]=housecode -> mid("[MACRO1]",1,1)
(This could be hardcoded if only one housecode will use this, but I leave it generic to quickly Multi-X enable another housecode for SlimPad use. Note though that there may be a conflict if you use the same housecode for both the PalmPad Multi-X and KeychainRemote Multi-X. If this is desired, you may need to put the KeychainRemote on a separate housecode and hardcode the housecode for which the functions should be interpreted into the macro.)

[MACRO3]=unitcode -> if(integer(mid("[MACRO1]",7,2))-14>1,3,1)+if(mid("[MACRO1]",9)="03",1,0)+if(mid("[MACRO1]",2,2)="16",4,0)

And the Send Key command looks like this (after doing an error check to make sure the unitcode is >0 as mentioned above)

Send Keys "{x10+[MACRO2]+" + [MACRO3] + "+0}{x10+[MACRO2]+1" + mid("[MACRO1]",4,2) + "+0}"
Back to Top View hollis's Profile Search for other posts by hollis Visit hollis's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 18 2002 at 11:39 | IP Logged Quote dhoward

Hollis,

Looks great!! Im glad someone is really making use of the multi-x features. When the next version comes out with the export features, you'll have to send the macros up and I'll post them on the site.

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

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