View Full Version : Serial Insteon Powerlinc, X10:Level Lua command - Can I get correct syntax?

July 31st, 2008, 07:34 PM
I'm trying to send direct X10 level commands via LUA instead of doing multiple repeats of DIM or BRIGHT.

It seems to me that I should be able to do this by:

X10:Level(hc,uc,X) -- where X is my dim level in %Only problem is, this is a complete guess. There is no documention on the Level command. I can only guess the syntax must be similar to:

X10:Send(hc,uc,fc) because that actually works when I try it. But when I attempt to send the Level code this is what I get in the Lua console:

.\scripts\x10.lua:1184: bad argument #1 to `min' (number expected, got nil)
stack traceback:
[C]: in function `min'
.\scripts\x10.lua:1184: in function `LevelDirect'
.\scripts\x10.lua:1176: in function `Level'
[string "LukeTest.gml:\New\Scripting"]:5: in main chunk

I've tried all kinds of variations and typically get the same error message. Does anyone know the correct syntax to this command? Also, can anyone explain to me the different between Level and LevelDirect? (For that matter, the difference between Send and SendDirect?)

What would be nice is if I could actually inspect the x10.lua file that is mentioned in the error message - if I could do that, presumably I might be able to figure out the syntax for these functions instead of posting these bothersome messages on the forum. There is in fact an x10.lua file located in my Girder install directory in the \luascript\DeviceManager\Providers\ subfolder, but it does not appear to be the same file mentioned in the error message. At any rate it doesn't have 1,184 lines, nor can I see in it any functions titled "Level" or "Send" or the like.

Any help is appreciated,


August 4th, 2008, 05:22 PM
These APIs are not intended for general consumption. Sorry. You'll have to use the normal Actions on the tree. They allow you to set the level directly as well.

August 4th, 2008, 06:26 PM
Ron, thanks for the reply.

By the normal actions on the tree, I presume you are not talking about the "Device Command" or "House/Unit Code Commands" under the X10 node of the Action tree, since I can't see how either of those would allow the sending of direct dim levels, unless I am missing something. Perhaps there is a way to do it using the "EXTENDED CODE" command or the like, but I have never been able to figure out where you put the extended code at.

If I am not mistaken that leaves only the lighting commands under the Device Manager node.

In a post by Rob H. in another thread, he mentioned that you could not put multiple DM lighting commands in a macro, as "the DM will aggregate the changes without delays between them." In my experience this is true. I can send direct dim levels using the DM actions, but not in a macro - they only work when executed individually. What then is the method used to have a single command run multiple DM lighting actions sequentially? I have tried to insert "waits" and "timers" between my actions but this still doesn't work.

I would put a link to Rob's post but the forum won't allow me because I am too new. It doesn't much matter, as he only says it is a limitation, but not how to work around it.

Nevertheless, I suppose in some ways I still have the same question - whatever the tree action is that I'm supposed to use to send direct dim levels, and however it is that I'm supposed to overcome the macro issue, is there still a way to script this tree action in LUA?


August 10th, 2008, 02:45 PM
Ok, my 30 day trial of Girder is quickly approaching an end. I still can't get a macro to run a series of sequential Device Manager Lighting actions. I have to say that support for this product doesn't quite seem to match the price paid for it. Nevertheless I'm happy to buy it, only I need to know first whether it can work for my needs.

I reiterate my question - how do I send sequential, direct-dim level commands in Girder? When I try to put multiple Device Manager lighting actions in a macro, they get garbled. I can execute each action independently using F5, and they work, but not strung together in a macro. Attempting to use Wait and Timers doesn't seem to help. What's the trick?


August 10th, 2008, 10:13 PM
The Wait should really do the trick. Can you post an example of a macro that does not work?

August 11th, 2008, 11:32 AM
Here is the GML I am testing. If there is some other format I should be posting this as, let me know.

I've also posted a screenshot from the logger. You will see at the bottom that it goes through the commands sequentially, with the Waits running as expected. However, during this time (I have my waits set to a very slow 3 seconds each), my Powerlinc does nothing. Only after all the actions have been "completed" (ie, ignored), then when the whole process is over do you see the DM start sending out commands. That is when I see the light on the Powerlinc start flashing like crazy. However, my lamps never respond as they should, probably because all the commands seem to be sent out at once, no doubt flooding the line. Typically the lights do nothing, though occasionally one might do what was intended - but never all four.

What isn't captured in this screenshot is that sometimes, the flood of commands will actually cause the Smarthome Device Manager to restart.

Let me also add - if you can give me a LUA command comparable to the PowerLincU.SendExtended, only not for the PowerLinc USB but for the Insteon PowerLinc Serial, or for that matter some kind of X10:SendDirectLevel command, if it exists, then we may be able to solve my problem that way as well. I have no attachment to DM only I don't know any alternate methods to send direct dim levels to my X10 devices.

PowerLincU.SendExtended works perfectly, only I am unable to use the PowerLinc USB on this computer due to conflicts that it has with other software; this is entirely a problem with SmartHome's design of the USB PowerLinc. Hence my switch to the Serial Insteon device.

Let me know what other information I can provide.


Rob H
August 11th, 2008, 11:37 AM
Hmm... the only way to do this might be to split the macro up into the individual actions and use a gir.TriggerEvent() Lua action to fire the next action in the macro. Wait may not work actually, so perhaps set a timer to trigger the next action.

Having said that, I haven't tried this.

August 11th, 2008, 12:49 PM
That might work, but I'd like to get a little closer to the cause of the bug.

Can you set LogLevel in the plugins\treescript\PowerlincSerial.lua file to 0 (around line 125). and open the lua console and the logger and monitor the output. Please copy and paste the output here.

August 11th, 2008, 01:33 PM
Ok, here we are.

First of all, I found the PowerLincSerial.lua file in the Plugins\Serial\ folder, not Plugins\treescript\, if that makes any difference.

I changed the LogLevel to zero and ran my macro again. This time you can see that SDM actually restarted itself completely. I have done this several times and sometimes SDM restarts, and other times it doesn't. Either way the X10 commands don't go through.

If there is some way to copy and paste the actual text from either the Lua Console or the Logger, I have not been able to figure it out. I have tried several things and it seems like it should be possible but it doesn't work. So once again I am just attaching screen shots.


August 11th, 2008, 01:39 PM
Hmm that is confusing. What hardware do you actually have?

August 11th, 2008, 01:58 PM
My controller is an Insteon PowerLinc V2 Serial (model 2414S). However I don't have any Insteon devices currently, I am controlling X10-only LampLincs.

As I mentioned, I also have a PowerlincUSB (non-Insteon) and it works great with the PowerLinc USB plugin. Unfortunatley SmartHome's implementation of the HID drivers for this PLC cause all kinds of problems with other software, which is why I have switched to the Serial version. I wish there were comparable LUA commands for the serial side of things the way there are with the USB Powerlinc.

However, even with my Insteon Serial PowerLinc, when I use the LUA commands that I am aware of, such as X10:Send(hc,uc,fc) I get flawless results. That is why I have been asking if there is a way to send direct dim levels through code in a similar fashion, since this seems to work well.

I probably shouldn't mention this but I do seem to have gotten my lamps to turn on sequentially using SimpleTimers. I am using four timers for four lamps and this is anything but an elegant solution but it does work. I would still be interested in your comments on these other issues, however.


August 11th, 2008, 02:04 PM
I see, this is the new Serial Insteon Powerlinc stuff. I will update the title of this thread to make that clear. This is a 3rd party plugin written by Mike C.