Can one read Device Link information from python?

Posted on
Wed Jun 29, 2016 8:41 am
gsbrewer offline
Posts: 28
Joined: Jan 22, 2016
Location: Livermore, CA

Can one read Device Link information from python?

Is there any way to read Insteon link information from a device (and scene) within python? I seem to have a gremlin in my system somewhere (maybe line noise?) that corrupts links and scenes (linking to nonexistent devices etc). I would like to write a routine that looks for all devices listed in scenes (and device-to-device links) for any unknown device IDs /addresses, then send myself a flag for the devices and scenes to review manually.

When a bad link or scene is activated, the 2413U goes on vacation for about 20 minutes... messages come in from my Z-Wave Fibaro multi sensors, but no commands will go out to any device (neither from the UI nor from my python plugin) - just time-outs from every Insteon device. The Insteon network is locked up. During the 20 minute break, I have tried resetting the 2413, re-linking everything, but alas still no outbound commands (either from my plug-in nor from the UI). The only cure is time.

This happens every few weeks, but I'm not sure what device is causing the issue. Unfortunately, I have hundreds of devices and manually going through them to evaluate every link on a device-by-device basis in indigo takes an enormous amount of time... but after I am done (and delete all the bad links), it works fine for a few weeks.

I apologize if this request is elsewhere on this site, but I couldn't find it with the phrases I tried to type.

Thanks for any help

UPDATE: This timeout problem happened again and I found that I have bad parameters in some device links. In particular a companion light switch links to a load switch (each end of hallway scenario). The companion switch was trying to send the load switch 255 for brightness level. So any way to read link information from devices would be handy to help me automate my search for the link problems. My hope is that if I repeatedly run this script fro all my devices (and comparing results to command logs), I may eventually find out what is causing the corruption in the first place. So far I don't think it is isolated to a single device, but alas I have not been able to force the problem to occur on demand so its a long painful waiting game.

Posted on
Wed Jun 29, 2016 5:54 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Can one read Device Link information from python?

So there isn't an official public API to get the information, but here is the raw command used by the Indigo Cocoa client:

Code: Select all
links = indigo.rawServerRequest("GetLinksForDevice", {"Name":"deviceNameHere"})
indigo.server.log(unicode(links))

Since it isn't a public API there are no guarantees of course that the argument or return structures won't change, but thus far it isn't changing for Indigo 7. It returns 3 different lists, one with the controller links, responder links, and one with the empties (just ignore that one). You can see the Event Log dump (2nd line above) to figure out how to parse it. If it proves useful but you need information on some of the flag fields then let me know and I'll dig up the info from the header files.

The link corruption problem you are seeing is a real pain. It seems to crop up for users that have lots of INSTEON modules. In those cases the INSTEON traffic can cause corrupt links to be passed into Indigo. INSTEON using checksums for data integrity, but these corrupt packets get past that and are passed to Indigo. I suspect internally in the PowerLinc the message buffer gets stomped on and that the messages themselves aren't corrupt but the buffer passed to Indigo is. I haven't found any way to avoid or detect the problem on the Indigo side, unfortunately. I would suggest you keep the global re-sync-the-world attempts to a minimum. The less syncing you do, the less corruption you'll have since the corrupt links occur during reading of links. If you have modules that get corrupt links spontaneously (without a sync), then that is a different issue and I suspect the flash memory in the module is failing.

Image

Posted on
Wed Jun 29, 2016 6:01 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Can one read Device Link information from python?

Also, here is another thread that has a bit more details and tips on using that private request API.

Image

Posted on
Tue Jul 12, 2016 4:23 pm
gsbrewer offline
Posts: 28
Joined: Jan 22, 2016
Location: Livermore, CA

Re: Can one read Device Link information from python?

Thanks so much for your thoughtful and insightful response Matt... much appreciated. And keep up the great work!

Posted on
Tue Jul 19, 2016 9:49 am
gsbrewer offline
Posts: 28
Joined: Jan 22, 2016
Location: Livermore, CA

Re: Can one read Device Link information from python?

I am effectively reading the Powerlinks now. Thank you for that helpful information. I would like to verify that the results I am getting are normal...

After issuing these commands:

links = indigo.rawServerRequest("GetLinksForDevice", {"Name": "PowerLinc Interface"})
indigo.server.log("### Start PowerLinks" + unicode(links))

I see all my PowerLInks and can parse them quite well, however I also get Group 1, "unknown device" entries. I assume these are deleted, unused devices (resulting from device replacement over the years) and they are not harmful to the system. Is this correct? If so, are these entries recycled at some point?

Example unknown device:

Link : (dict)
Address : 1403870 (integer)
AddressStrUI : 15.6B.DE (string) ### I don't have such a device
AddressValUI : 1403870 (integer)
ControllerDevClass : 0 (integer)
ControllerDevFlagsUI : 0 (integer)
ControllerInstnFlagsUI : 0 (integer)
ControllerInstnLinksDbFormat : 0 (integer)
ControllerInstnTypeIdUI : 0 (integer)
ControllerNumControlGroups : 0 (integer)
Data1 : 0 (integer)
Data1UI : 0 (integer)
Data2 : 0 (integer)
Data2UI : 0 (integer)
Data3 : 255 (integer)
Data3UI : 255 (integer)
DataValid : 1 (integer)
DeviceNameUI : unknown device (string) ### I don't have such a device
GroupNum : 1 (integer)
GroupNumUI : 1 (integer)
IsThreaded : true (bool)
MemoryLoc : 0 (integer)
ObjVers : 6 (integer)
Persistent : true (bool)
RawFlags : 3 (integer)
ResponderDevClass : 0 (integer)
ResponderDevFlagsUI : 0 (integer)
ResponderInstnFlagsUI : 0 (integer)
ResponderInstnLinksDbFormat : 0 (integer)
ResponderInstnTypeIdUI : 0 (integer)
ResponderNumRespondGroups : 0 (integer)
RuntimeID : 508 (integer)
RuntimeID_bl : 0 (integer)
Status : 1 (integer)
Type2 : 1 (integer)


Thanks again for your assistance!

Posted on
Tue Jul 19, 2016 6:15 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Can one read Device Link information from python?

Do they show up in Indigo's UI for the PowerLinc (on group/scene 1)? If they don't show up in the UI, then they are unused empty entries that have been flagged as erased but aren't used. If they show up in the UI but show as an unknown device in the UI, then the link should probably be deleted in Indigo. If it isn't and you have cleanup-commands option turned on (in prefs dialog for PowerLinc), then it will try to send a clean-up command to that device. If it doesn't exist anymore, then it will result in retries and additional unneeded network congestion.

The PowerLinc can hold a lot of links, so if it just an empty slow then you can just ignore it.

Image

Posted on
Wed Jul 20, 2016 8:28 am
gsbrewer offline
Posts: 28
Joined: Jan 22, 2016
Location: Livermore, CA

Re: Can one read Device Link information from python?

The unknown links do not show up in the indigo UI. I will ignore them. Thank you!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests