Loading and printing hub database?

71 views
Skip to first unread message

Daniel Ruggeri

unread,
Apr 22, 2022, 4:16:09 PM4/22/22
to insteon-terminal
Hello, Daniel and all;
   I've been working with insteon-terminal for a while. I have so far been able to interrogate the network and have also used it several times to diagnose and clear dead links every couple of months when switches would give the red feedback light. Unfortunately, I never quite could download my Hub's database.

   Where I am currently failing is trying to figure out how to get the hub's allDB and save it to file/print it. I have tried creating a new device with `Modem2413U("Hub", addr)` and attempts to call .getdb() hang for a long time.... but eventually I see:

Reading database attempt 1 for 34.48.1E (Hub)
Modem Link DB complete!
Failed to initialize python interpreter:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./init.py", line 87, in <module>
    db, isSane = device.readdb()
TypeError: 'instance' object is not iterable

The first line of output is from my init.py file (in addition to just initializing the terminal, I am also looping through known devices in a config file and making sure I have the linkdb for each so I can perform local analysis). From what I can tell, the other lines of output from a failure somewhere inside insteon-terminal that I cannot track down. I recognize the "Modem Link DB complete!" line from the python code. I am only calling readdb() on the modem object and the next line of output should be a print statement from my calling code indicating the read worked or was not sane. So, I'm stumped on what instance is not iterable per the error message

My calling code is like this (the inner loop of interest):
      tries += 1
      print("Reading database attempt " + str(tries) + " for " + address + " (" + name + ")")
      db, isSane = device.readdb()

      if isSane:
        print("  Successful read")
        break
      elif len(db.getRecordsAsArray()) > 1:
        empties = 0
        print("  Last read not sane, but records detected. Trying again...")
      else:
        empties += 1
        print("  Last read not sane and no records detected... Trying " + str(3 - empties) + " more times")



   I am asking because, like lots of Insteon users, the smart phone app isn't very helpful anymore. So, I'm working on a script to automate the reverse engineering of scenes so I can plug them in to Home Assistant. Therefore, I need to figure out what the group IDs are from the Hub's point of view.

Thanks in advance for any assistance or pointers

Daniel Ruggeri

unread,
Apr 22, 2022, 7:40:18 PM4/22/22
to insteon-terminal
I just remembered about setting debug logging - this did not produce any additional lines of input related to the failure:
Reading database attempt 1 for 34.48.1E (Hub)
23:32:46.105 [Thread-3] DEBUG us.pfrommer.insteon.msg.IOPort - Msg written: OUT:Cmd:0x69|
....
23:37:49.654 [Thread-2] DEBUG us.pfrommer.insteon.msg.IOPort - Msg received: IN:Cmd:0x6A|ACK/NACK:0x15|
23:37:49.656 [Thread-2] TRACE us.pfrommer.insteon.msg.MsgReader - processing data: len 0 data:
23:37:49.656 [Thread-2] TRACE us.pfrommer.insteon.msg.MsgReader - msgLen expected: -1
23:37:49.656 [Thread-2] TRACE us.pfrommer.insteon.msg.MsgReader - keeping buffer len 0 data:

Modem Link DB complete!
Failed to initialize python interpreter:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./init.py", line 88, in <module>

    db, isSane = device.readdb()
TypeError: 'instance' object is not iterable
23:37:49.693 [MainThread] INFO  u.p.insteon.terminal.InsteonTerminal - Terminal started

Zach Hawkins

unread,
Apr 23, 2022, 11:36:48 AM4/23/22
to insteon-terminal
Just another user here, by no means an expert, but I think you may be focusing on the wrong part of the error message. I think this is returning a "TypeError" on your assignment of isSane to the return of the readdb() function. My guess is the readdb does not return a data type that can be resolved to a isSane. When you call readdb() in the terminal directly it returns the entire database. 

For example when I made a capitalization mistake in my init.py file I got the following:

Failed to initialize python interpreter:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./init.py", line 50, in <module>
    FamilyOutlet  = Switch2477s("Family_Outlet", "44.0C.47")
NameError: name 'Switch2477s' is not defined

The correct name was 'Switch2477S'. In my case it was a NameError, in your case its a TypeError. Quick Google search on Python TypeError and you get: 

exception TypeError

Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch.

This exception may be raised by user code to indicate that an attempted operation on an object is not supported, and is not meant to be. If an object is meant to support a given operation but has not yet provided an implementation, NotImplementedError is the proper exception to raise.

Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError.

Reply all
Reply to author
Forward
0 new messages