PDA

View Full Version : CM15a



ylaviolette
November 11th, 2009, 10:38 PM
Sorry to cross post but based on the lack of feedback, I thought maybe users are not looking at "girder 4" any longer, so here it is:

Has anyone been successful at using "direct dimming" on the X10 CM15a?

I have newer x10 "soft start" modules (ws12a, xps3, etc) which have a "direct dim" feature (ability to turn on at the desired level), I would like to use this feature but unfortunately I can't figure out how to use it through Girder

The older style x10 devices will go from 100% then dim but require only ONE (DIM) command to do so. Without access to "direct dimming", newer "soft start" modules require THREE steps (ON,DIM to 0,BRIGHT) to achieve the same thing and a much longer delay.

Can the CM15 plugin (or another Girder supported device: powerlinc, cm11a, etc) send "direct dim" commands, either directly or through a series of commands?

It seems this is achievable from a hardware perspective, see these links:


http://www.smarthome.com/forum/topic.asp?whichpage=1&TOPIC_ID=1606#30257

http://forums.x10.com/index.php?topic=16552.0below

ftp://ftp.x10.com/pub/manuals/xtdcode.pdf


but I have to figure out if Girder can achieve this and how.

So far it it looks like Girder supports the "old" style preset dim function which is not implemented in "soft-start" x10 modules (they use the newer "direct dim" commands)

Also, if this has to be done with a serial controller, could I use a usb converter?


Any assistance would be greatly appreciated

Rob H
November 12th, 2009, 06:09 AM
I'll have to leave this for Ron, I don't have any working X10 hardware at present, nor indeed access to the sources for this plugin.

Ron
November 12th, 2009, 10:07 AM
You can always use a macro to send 3 commands manually.

ylaviolette
November 12th, 2009, 10:22 AM
This is the way I currently use it, however this means a sequence that takes a long time to complete when in fact the CM15 can send a "direct dim" to the modules. This avoids the delay and the lights do not ramp up and down for nothing. Also, from what I read, this feature can allow the user to define the ramp up/down delays and supports "grouping" of modules.

Have a look at the links I provided above, they are really clear on the feature details and the protocol seems pretty well defined.

Worst case could you let me know who developed the CM15 plugin (or CM11a or Powerlinc)? I'll try to see if this is something achievable.

In fact, I don't even mind changing my controller/plugin to something else, the objective here is to have access to "extended dimming". This is supported by both Leviton and newer X10 modules and frankly is a must have.

Thx again for all your help. I have to make a choice between Girder and Homeseer and I'd really like to go for Girder 5. However, Homeseer does support "extended dimming'" with many controllers (not the CM15 but the USB Powerlinc and many serial units); I'd like to push a little further just in case I can get some workaround with Girder.

Ron
November 12th, 2009, 10:45 AM
Sadly I have no time to spend working on this. But I'll upload the source code for the cm15 and X10 support.

download both attachments and place them in the luascript directory.

I've seen some dimming referencing in the cm15 file,... so this might work with a little tweaking.

Enable the Cm15 plugin to start using the cm15-work file. You'll see


Cm15 work
x10-work

in the console to indicate you loaded the script files.

ylaviolette
November 12th, 2009, 11:31 AM
Did you develop this plugin? If not is it possible to know who? Unfortunately I am not really familiar with Lua scripting... I'll have to start from scratch but if that's the way to go maybe I'll give it a try. Thx

Ron
November 12th, 2009, 11:51 AM
Sadly, I did not develop this particular one. I can look at it when I get some time but currently I am swamped.

ylaviolette
November 12th, 2009, 12:05 PM
I believe it's Mike C, I'll drop him a PM. Thx

ylaviolette
November 12th, 2009, 06:36 PM
fyi, I've downloaded the SDK from

http://www.activehomepro.com/sdk/index.html

They provide a command line application (AHCMD.EXE) which enabled me to use extended commands ( ftp://ftp.x10.com/pub/manuals/xtdcode.pdf ) ( http://forums.x10.com/index.php?topic=16648.0 ) this is a great improvement over regular commands:

1 - you can "direct dim" modules (recent x10 or leviton) to any level (TESTED -OK )

2 - You can group "direct dim" commands so they'll be executed simultaneously instead of being triggered in sequence. (TESTED - OK)

So far I'm just plainly using "file execute" to trigger the command line and batch files but it would be great to see this integrated to the CM15 plugin / device manager because the main downside is that you have to redo everything if you change house/device codes.

Hopefully Mike C or someone could provide feedback on the complexity of adding this to the plugin.

Thx again.

Mike C
November 16th, 2009, 11:19 AM
i had a quick look at the code and it seems i did implement direct dim. how are you trying to send the command?

ylaviolette
November 16th, 2009, 01:12 PM
Hi Mike, thanks for taking some time to check this; I am glad to hear that there is some hope to get this working.

Technically, the way to achieve it is the following sequence:

- Send house code A1
- Send Extended Code 31 1F (31 being the code type and 1F the brightness, all in HEX)

or "sendplc A1 extcode 31 1F" when I use the command line.

This will trigger a "direct dim" of unit A1 (Brightness range is 64 levels from 00 to 3F)

In fact this is one of many new possible commands but they all roughly use the same format "sendplc xx extcode xx xx" but sometimes requires multiple commands to achieve a general task (grouping modules for instance)

Have a look at these threads for additionnal info

http://forums.x10.com/index.php?topic=13144

http://forums.x10.com/index.php?topic=16648.0

I couldn't figure out a way to send these in sequence with current girder commands; in the device command menu the only additionnal option is "level" which I couldn't figure a way to use (not documented, found nothing in the forums) and under general X10 commands, there is an "extended code" option, however I don't see where I could add the required parameters (and these commands lack the benefit of the device manager)

Let me know how this looks, I'll make some tests based on your reply.

Thx again, much appreciated.

Mike C
November 16th, 2009, 03:23 PM
ok, so you are using extended x10 for sending these commands - right?

non of the x10 stuff in G uses the extended command set.

so, to do this, in the cm15a file, change this line

local ActiveHome -- luacom object, init below

to

ActiveHome = {}

this will make the com object available in G.

you then need to use the object like....

ActiveHome:SendAction ("sendplc", ...)

ylaviolette
November 16th, 2009, 05:52 PM
Thx Mike, yes these are all extended commands, here's what I did so far, let me know if this is correct:


- downloaded the two lua files provided by Ron earlier (CM15a-work.lua and x10-work.lua)

- copied these to the luascript directory

- opened cm15a-work.lua for editing

- located the line

"local ActiveHome -- luacom object, init below"

deleted the whole line and replaced it with

"ActiveHome = {}"

- restarted Girder

When you say "you then need to use the object like.... ActiveHome:SendAction ("sendplc", ...)" do you mean I need to use a scripting command? if so, could you give me a full example in order to send "sendplc a1 extcode 31 1F" ? Also, what would be the benefit of this method over using the sdk command line with "file execute" ?

Finally, will I have to keep the luascript files (CM15a-work.lua and x10-work.lua) active or is there any way to recompile and only us the cm15a.dll file? (is cm15a.dll a compiled version of the luascripts provided by Ron?)

Sorry, I have been using Girder for a while but other than setting variables, I am not familiar with the lua/scripting part.

Thx again.

Mike C
November 16th, 2009, 08:48 PM
yes, you will have to scipt. i cannot find a document on activehome describing how to use com object. do you have a link?

ylaviolette
November 16th, 2009, 09:03 PM
All the relevant information I found comes from these three forum threads

http://www.smarthome.com/forum/topic.asp?whichpage=1&TOPIC_ID=1606#30248

http://forums.x10.com/index.php?topic=13144

http://forums.x10.com/index.php?topic=16648.0

+ the protocol/sdk provided by X10

ftp://ftp.x10.com/pub/manuals/xtdcode.pdf

http://www.activehomepro.com/sdk/index.html

Unfortunately, I am not familiar with the "com object" used in Activehome but I am sure my good Samaritan from the X10 forum knows about it. I will try to bring him over to this thread to comment.

Thx

Mike C
November 17th, 2009, 02:25 PM
from the lua console try

ActiveHome:SendAction ("sendplc", "a1 extcode 32 09 ")

Mike C
November 17th, 2009, 02:45 PM
that means the changes to the cm15 file did not take. where did you put this file?

you could cut and paste the contents of that file in a scipt action, run it. then try the above.

ylaviolette
November 17th, 2009, 02:53 PM
Great, this works. (forget the first post, I had not restarted Girder)

Questions:

1 - Is cm15a.dll a compiled version of the luascripts (CM15a-work.lua and x10-work.lua) ?

2- Is there any way to recompile and only use the cm15a.dll file?

3- Could this feature be integrated to the device manager (device commands) ?

Thx for your assistance!

Mike C
November 17th, 2009, 03:03 PM
ron can recompile this

integration is possible but not all that simple - and i can't spend too much time on it...

if you look at x10-work you will see



LevelDirect = function (self,hc,uc,level) -- level in %
-- call to send without updating devices, if x10 interface echos command, then status is tracked
-- ie. this function sends only and does not update or notify of change.
-- this is called by the x10Device class
level = math.min (level,100)
level = math.max (level,0)

local d = self:FindDevice (hc,uc)

if d then
if d.Abilities.Dim == 4 then -- leviton dim
if Ocelot then
Ocelot:LevitonDim ( hc, uc, level)
else
-- print ('Leviton Dim not implemented for this x10 provider')
cm11.LevitonDim(hc, uc, level)
end

change these lines

if Ocelot then
Ocelot:LevitonDim ( hc, uc, level)
else

to

if Ocelot then
Ocelot:LevitonDim ( hc, uc, level)
elseif ActiveHome then
ActiveHome:SendAction (--what ever you need to send here --)
else



ie you are inserting these 2 lines.

elseif ActiveHome then
ActiveHome:SendAction (--what ever you need to send here --)

ylaviolette
November 17th, 2009, 03:20 PM
I get this in the lua console:

compiledlua: C:\Program Files\Girder\\luascript\x10-work.lua:1201: unexpected symbol near `else'

ylaviolette
November 17th, 2009, 03:34 PM
File attached for your review. thx

Mike C
November 17th, 2009, 03:55 PM
you will need to change what i wrote to send the proper command. ie replace what is between the -- -- with the right stuff. you have to use the hc,uc,level variables to create the right string to send.

ylaviolette
November 17th, 2009, 04:38 PM
Sorry about that, I thought what was between the brackets was just a comment.

I managed to get this working for one type of command at a time but unfortunately the extended commands are far more complex than the old "preset dim" used in this part of the code.

Reworking the CM15a plugin to correctly integrate it would require someone who has both a good knowledge of the logic involved in handling the extended commands (I am OK with this part) and knows how to code Lua (unfortunately my knowledge there is too limited)

If someone wants to give it a try, in order to at least integrate the basic "direct dim" command, the format required would be:

sendplc A1 extcode 31 0F

"sendplc" is just text and constant
"A1" is the house code (hc)+ device code (dc)
"extcode" is just text and constant
"31" is the command type for direct dim therefore constant
"0F" is the level (64 levels between 00 and FF in hexadecimal)

The scripting option is already a great improvement and will fulfill my needs at this point.

Ron, if you are around let me know if you could recompile cm15a.dll with the modified cm15a-work.lua (attached)


Thx again for your help!

PS: These new commands are great and add tremendous value to the newer X10 modules. So if someone is interested in taking over the Cm15 plugin rework from here please let me know, I'll be more than interested in testing it.
I guess if someone knowledgeable in Lua goes through the links I have posted earlier, this could probably be achieved.

Mike C
November 17th, 2009, 07:49 PM
ok, that is fairly easy and would look like


ActiveHome:SendAction ('sendplc',hc..uc..' extcode 31 '.. string.format ('%x',64*level/100))

ylaviolette
November 18th, 2009, 07:25 AM
Thx Mike, I made the corrections to the x10-work.lua file and it loads smoothly in the lua console; now, how can I trigger the command? I have tried to use the "level" command but it still sends the old "preset dim" command... Let me know where I should find it. Thx

Mike C
November 18th, 2009, 03:23 PM
on the x10 device config page, make sure you have use leviton dim selected for each device you want to use extended dim with.

ylaviolette
November 18th, 2009, 03:41 PM
Here's what I get:

TreeScript (gir_event): COM exception:(.\src\library\tLuaCOM.cpp,394):expectin g: sendplc extcode command data (in hexadecimal)
stack traceback:
[C]: in function `SendAction'
C:\Program Files\Girder\\luascript\x10-work.lua:1200: in function `LevelDirect'
C:\Program Files\Girder\\luascript\x10-work.lua:1542: in function `Command'
...\Program Files\Girder\/plugins/treescript/x10 UI.lua:840: in function <...\Program Files\Girder\/plugins/treescript/x10 UI.lua:809>


I am sure you know your stuff, but are you positive this "('%x',64*level/100)" will generate an hexadecimal value ?

as I said: "0F" is the level (64 levels between 00 and FF in hexadecimal)

Thx

Mike C
November 19th, 2009, 12:42 PM
ok, something wrong with the code - i do not have a working G install right now (moved a little while ago).

rob should be able to help fix that line of code.

rob? ;-)

ylaviolette
November 19th, 2009, 12:57 PM
Thx Mike, I'll for wait for Rob's feedback.

Rob H
November 19th, 2009, 07:21 PM
That code looks pretty much okay to me, and seems to test correctly, at least the part that generates the level as hex.

Remind me about this tomorrow

Mike C
November 19th, 2009, 09:18 PM
then its our format of the command thats wrong.

did you cut and paste the code or type it... if there are spaces missing or something else, there is an assertion.

ylaviolette
November 20th, 2009, 07:29 AM
I did a cut and paste; have a look I have attached the file. Let me know if something is wrong. Thanks for your help.

Mike C
November 21st, 2009, 08:23 PM
this won't fix it, but show me the output here

ylaviolette
November 22nd, 2009, 08:34 AM
Great, I see you have put some logging and indeed there seem to be a problem with the Hex conversion, (find results below) In order to help, I have called levels 0,15,31,47 and 63. As you will see they don't generate the correct hex output, however since some of them generated a valid output (31,47,63), I can confirm that the command itself works. Thx for your help, keep me posted.

BTW, single digits results require a zero in front. Ex: 9 must be 09. thx


E 9 0
sendplc E9 extcode 31 0
TreeScript (gir_event): COM exception:(.\src\library\tLuaCOM.cpp,394):expectin g: sendplc extcode command data (in hexadecimal)
stack traceback:
[C]: in function `SendAction'
C:\Program Files\Girder\\luascript\x10-work.lua:1202: in function `LevelDirect'
C:\Program Files\Girder\\luascript\x10-work.lua:1544: in function `Command'
...\Program Files\Girder\/plugins/treescript/x10 UI.lua:840: in function <...\Program Files\Girder\/plugins/treescript/x10 UI.lua:809>
E 9 15
sendplc E9 extcode 31 9
TreeScript (gir_event): COM exception:(.\src\library\tLuaCOM.cpp,394):expectin g: sendplc extcode command data (in hexadecimal)
stack traceback:
[C]: in function `SendAction'
C:\Program Files\Girder\\luascript\x10-work.lua:1202: in function `LevelDirect'
C:\Program Files\Girder\\luascript\x10-work.lua:1544: in function `Command'
...\Program Files\Girder\/plugins/treescript/x10 UI.lua:840: in function <...\Program Files\Girder\/plugins/treescript/x10 UI.lua:809>
E 9 31
sendplc E9 extcode 31 13
E 9 47
sendplc E9 extcode 31 1e
E 9 63
sendplc E9 extcode 31 28

Rob H
November 22nd, 2009, 09:29 AM
Okay, change the format string to "%02X" and you should be fine.

ylaviolette
November 22nd, 2009, 10:51 AM
Great, this works; I have just changed the base to 64 instead of 100 to reflect the exact number of levels, which gives:

elseif ActiveHome then
print (hc,uc,level)
print ('sendplc',hc..uc..' extcode 31 '.. string.format ('%02X',64*level/64))
ActiveHome:SendAction ('sendplc',hc..uc..' extcode 31 '.. string.format ('%02X',64*level/64))
else

it stills let's the user enter values up to 100 (any way to block it at 63?) but this is no big deal.

I also kept the 2 lines of lua logging just in case, if it's better to get rid of it let me know.

Thx

Rob H
November 23rd, 2009, 08:23 AM
I'd suggest restoring it to 100 - that's what DeviceManager expects as far as I can recall.

Mike C
November 23rd, 2009, 08:40 AM
i wonder if the last part needs to be 00 and not 0

rob, what changes to the hex conversion are needed to give 2 digits? is it %02x?

Rob H
November 23rd, 2009, 09:00 AM
Yes, it's the %02X ie field width of two, pad left with 0 and use uppercase (rather than 'x' which would be lower case)

ylaviolette
November 23rd, 2009, 01:52 PM
1 - Can't the device manager simply restrict the field to values between 0 and 63 ? Except if you tell me that it can mess with the engine (which doesn't seem to be the case, since I had no issues whatsoever), I'd rather keep 64; the 100 base creates an average which messes things up (IE: 100% will generate hex value of 40 instead of 3F, therefore no action; 0% and 1% will return the same results,etc.)

2- Any problem keeping the logging part:

print (hc,uc,level)
print ('sendplc',hc..uc..' extcode 31 '.. string.format ('%02X',64*level/64))

or should we get rid of it?

Thx

Mike C
November 23rd, 2009, 08:23 PM
get rid of the logging...

definitely need to use 100 as the base

how about changing the 64 to 63 for the multiplier?

ylaviolette
November 23rd, 2009, 08:43 PM
Ok will try, can you confirm this is it (below) and what I should expect compared to the other form?

ActiveHome:SendAction ('sendplc',hc..uc..' extcode 31 '.. string.format ('%02X',63*level/100))

Thx

Mike C
November 23rd, 2009, 09:00 PM
looks good. that should give you levels 0-63

ylaviolette
November 23rd, 2009, 09:14 PM
OK great this works,

If Ron or someone else has 2 sec, would you be kind enough to recompile the files (attached) into a new .dll ?

thanks to all for your support!

NB: Since all extended commands are now supported through fairly simple scripting, it is also possible to use the "scenes/groups" features, which I already implemented for myself. However, if someone is eventually interested in adding these more advanced features to the plugin itself, let me know and I'll be glad to help/test.

ylaviolette
November 30th, 2009, 02:28 PM
Any benefit in recompiling the files or can I stick with the 2 work files ?

Let me know, thx.

Ron
November 30th, 2009, 02:36 PM
No performance benefit at all. Just stick with those files for now.