View Full Version : Insteon Lua Question
tmorten
May 8th, 2007, 07:34 AM
Recognizing that the Insteon LUA interface isn't officially supported (and is therefore subject to change at any time), I'd like to take Mike up on his kind offer to answer the odd question about how to use the interface that's currently implemented.
Okay, here's what I'd like to do:
1. Detect a change in state of an Insteon dimmer
2. Retrieve the new state and store it in a variable
3. Send that variable value to NetRemote
The third step is obviously no problem, but I'm not quite sure about the first two. Here's what I know so far:
A. I can have a function called on each Insteon event using this code:
function InsteonDeviceEventHandler (eventtype,...)
print ('Insteon Event',eventtype,unpack (arg))
end
Insteon.DeviceManager:Subscribe (InsteonDeviceEventHandler)
B. I can poll Insteon device levels with this code:
function callback (...)
print ('got device level',unpack (arg))
end
Insteon.DeviceCommands.GetLevel (id,callback)
So, to connect the dots...
Is there a way to just trigger a callback when dimmers' states change (and perhaps even receive the new level at the same time)? Or should I have my "InsteonDeviceEventHandler" check the level of the Insteon DeviceID that's passed every time that there's communication (this seems like overkill)?
Many Thanks,
Tim
Promixis
May 8th, 2007, 08:01 AM
Tim, if you are on G5, the Device Manager does this all automatically. It definitely is the preferred way :D
You can also see all the devices on the G5 webserver
just point your browser to your url/dmex
tmorten
May 8th, 2007, 08:31 AM
Fair enough; I'll take the plunge and give G5 a try this weekend...
tmorten
May 10th, 2007, 06:33 AM
A couple more questions:
1. X10 Using the Insteon PLC
I note that there's a SendX10 function; what are the parameters? Also, I note that the event handler doesn't seem to get called when X10 is received... is there another way to trap incoming X10 with the Insteon PLC in G4 (or do I need to move to G5 for this)?
2. Polling
It seems like there's a constant stream of traffic in the SDM when Girder is running, that I don't see when running other apps that interract with the SDM. Is this just state polling, or is there something else going on in the background?
Many Thanks,
Tim
Promixis
May 10th, 2007, 05:55 PM
A couple more questions:
1. X10 Using the Insteon PLC
I note that there's a SendX10 function; what are the parameters? Also, I note that the event handler doesn't seem to get called when X10 is received... is there another way to trap incoming X10 with the Insteon PLC in G4 (or do I need to move to G5 for this)?
2. Polling
It seems like there's a constant stream of traffic in the SDM when Girder is running, that I don't see when running other apps that interract with the SDM. Is this just state polling, or is there something else going on in the background?
Many Thanks,
Tim
1. The X10 events are published via the X10 DM. You can get these via the X10:Subscribe function.
Events come back with the args Event,Device.
Again, the best way to deal with this is via the G5 DM. One system that works the same regardless of the underlying technology.
2. G4/G5 talks to the SDM to A. Poll Devices (set on the SDM page) and B. To keep updated link databases. I turn the later option off (SDM Page) and set polling at 90 seconds. If you SDM SALAD app is wrong, device deltas are not reported correctly and therefore G is constantly thinking the link databases have changed and therefore updates after every polling operation. Yuck.
vitello
May 11th, 2007, 06:10 PM
Mike,
You mentioned that you can turn off keeping an updated link database by turing off the option on the SDM Page. Are you talking about Insteon links? I am using Insteon Plugin Version 1.4.3 on G4 and the only options I see on the SDM page are: Enable logging to the lua console, Enabling logging to file, Days to keep log file, Device Polling Interval, and Get status for all devices at startup. Which option turns off the updates for the link database? I am continually getting broken links, probably due to noise.
Peter
Promixis
May 12th, 2007, 05:58 AM
Peter... looks like the Insteon plugin needs to be refreshed.
Should be up this weekend.
tmorten
May 12th, 2007, 07:26 AM
1. Peter - I ran the following in a short script:
Insteon.GlobalSettings.AutoDeviceAdd = false;
Insteon.GlobalSettings.AutoLinkUpdate = false;
I suspect this accomplishes what Mike was suggesting (though I could be wrong).
2. Mike - I'm seeing HUGE delays controlling Insteon devices in one particular room... sometimes 45 seconds or more, sometimes commands time out altogether. I tried moving a SignaLinc around between each of the outlets in the room, but it didn't help at all. Any suggestions? Even x10 didn't have that kind of latency! I wish Insteon were a true mesh network instead of relying on SignaLincs... it seems like Z-Wave and ZigBee have an edge in that regard.
Thanks,
Tim
Promixis
May 12th, 2007, 07:33 AM
1. Peter - I ran the following in a short script:
Insteon.GlobalSettings.AutoDeviceAdd = false;
Insteon.GlobalSettings.AutoLinkUpdate = false;I suspect this accomplishes what Mike was suggesting (though I could be wrong).
2. Mike - I'm seeing HUGE delays controlling Insteon devices in one particular room... sometimes 45 seconds or more, sometimes commands time out altogether. I tried moving a SignaLinc around between each of the outlets in the room, but it didn't help at all. Any suggestions? Even x10 didn't have that kind of latency! I wish Insteon were a true mesh network instead of relying on SignaLincs... it seems like Z-Wave and ZigBee have an edge in that regard.
Thanks,
Tim
Tim, open up the SDM, and see if it is sending the commands right away or not. Also, turn on lua console logging. See if you can tell if its the SDM just queuing the commands or a true lag (which it shouldn't be as Insteon should have given up long before 45 seconds).
tmorten
May 12th, 2007, 08:12 AM
Weird... the latency isn't happening now. My wife was using a blow-dryer at the time, so I wonder if it was just a by-product of electrical interference. Reliability is still poor on a couple of switches though... I see the send occur in SDM, but the switch just never responds. A few more tries and the command gets through, but it makes it feel flakey to have to do that. Probably a signal-strength issue, but any suggestions?
Thanks,
Tim
vitello
May 12th, 2007, 08:48 AM
1. Peter - I ran the following in a short script:
Insteon.GlobalSettings.AutoDeviceAdd = false;
Insteon.GlobalSettings.AutoLinkUpdate = false;
I suspect this accomplishes what Mike was suggesting (though I could be wrong).
2. Mike - I'm seeing HUGE delays controlling Insteon devices in one particular room... sometimes 45 seconds or more, sometimes commands time out altogether. I tried moving a SignaLinc around between each of the outlets in the room, but it didn't help at all. Any suggestions? Even x10 didn't have that kind of latency! I wish Insteon were a true mesh network instead of relying on SignaLincs... it seems like Z-Wave and ZigBee have an edge in that regard.
Thanks,
Tim
Tim,
Very useful. I took a look under Variable Inspector for the Insteon settings . I hadn't looked at the GlobalSettings table. I think setting AutoDeviceAdd and AutoLinkUpdate false should help stability. I also notices that in the Insteon table that my Directory while running G4 was set to "C:\Documents and Settings\Peter\Application Data\Promixis\Girder\5\Logs". There is no separate directory for G4 logs so it looks like G4 never saved logs and is using data settings from G5.
Peter
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.