Getting Caller-ID Notifications in Kodi

Had a notion to try to get incoming calls to show caller id on the Kodi screen. I looked around and found an add-on, called service.script.call-notifications (at github) by “mablae”, which sounds like it does what I want. It wants to get call data from one of three types of sources, one of which is named NCID (network caller ID). Looked into that and it sounds like just the thing.
NCID styles itself a client-server-gateway caller id system, and is somewhat like the callblocker thing which I built a few years back for the Raspberry Pi. But this one has the added feature that it will put caller id stuff out on the network, where users, like the Kodi add-on above, can use it. It will also do blacklisting, which was the purpose of the thing I built. And, like mine, it will run on the Raspberry Pi.
NCID says it wants to run on the Raspbian OS (a debian spin specifically for the pi). It can be compiled for other linux distros, but I thought I might as well use Raspbian. I had a spare 8GB SD Card, so I downloaded Raspbian, burned the card, brought it up on the Pi and spent a few hours getting it set up right (got rid of user “pi”, installed user “dee”, got the certificates set up right so I can ssh to it, and it can ssh to others,etc.), and then I installed the NCID code.
Installation of the code was a little unusual. It isn’t in any of the apt sources I have. I downloaded the deb files they had, and then used a program called gdebi to install them. gdebi seems to be a debian thing. I haven’t used gdebi before. I had to install it (with apt-get). Apparently it is like dpkg, but it handles dependencies, which dpkg doesn’t. Usage is just gdebi <deb pkg name>.
Had a little trouble with the modem being recognized and mapped correctly, but after a little futzing around it got added by udev as ttyACM0, and the daemon ncidd was then able to find it. A little program called ncid which is a little graphical client was able to connect, and able to detect calls. I set up ncidd to start automatically. It has a config file /etc/ncid/ncidd.conf in which I specify the device (ttyACM0) and how to hang up on blacklisted entries (I chose 2: play a fax tone first, then hangup). I left other things at default.

I left the Pi on ethernet. The little wifi dongle I have doesn’t do 5GHz, which is all the Access Point is putting out. Unless I want to set up a 2.4GHz radio for it (as I had at the old house) I’ll just leave it on ethernet. I will probably put the pi in the distribution panel in the basement anyway.
Next I installed the call notification thing in kodi (isengard). I downloaded the zip file from github, and then just told kodi to install from zip file. And it installed, or seemed to. But it didn’t work. Turned on debugging and tried to find the problem in the kodi log.
The zip file (when unzipped) has a main service.py, a directory called resources containing a directory called lib containing various things needed, including a directory called CallListenerClients with a file named NcidClient.py. Bottom line is kodi starts service.py but python chokes trying to import from the nested directories. I don’t know python well, so maybe there is some setting I haven’t attended to, but I solved the problem by simply moving the required imported python stuff (file CommonUtils.py and directory CallListenerClients) out of the nested structure and into the same directory with service.py. Unzip the directory, move stuff around, rezip, put it on the mac. Load it in kodi.
The other slight issue is that the caller name did not display properly either in Aeon Nox or Aeon MQ5. In particular my cellphone reports with the name “Longmont, Co”. The notice is displayed on a single line at the top of the screen, with “Longmont” in bold color, left justified and “Co is calling” in basic white, right justified. I thought the comma was probably causing the issue. After some debugging, I figured out that it was a problem with the invocation of the built-in function called XBMC.Notification. The invocation is done by building a string that contains the call, and then calling xbmc.executebuiltin with that string, e.g.

xbmc.executebuiltin(<outerstring>)

where <outerstring> is supposed to be something like:

XBMC.Notification(<innerstring1>,<innerstring2>,<int>,<path>)

The problem was that <innerstring1> was constructed and placed into the <outerstring> without being quoted, as it should have been. So what got generated for <innerstring> was:

'XBMC.Notification(Longmont,Co is calling!, 3035551212,10000,/path/to/icon.png)'

instead of:

'XBMC.Notification(“Longmont,Co is calling!”, 3035551212,10000,/path/to/icon.png)'

Obviously in the first form, the parameter ordering is messed up by the extra comma. By adding the quotes, it worked correctly. The Highlighted bit on the left of the screen is the name, and the non-highlighted bit on the right is the number.
Here is the changed code in service.py, although the line breaks are according to wordpress, not according to my code.

callerstring = xbmcAddon.getLocalizedString(30601) % caller.caller 
xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" % ('"'+callerstring+'"',
   caller.number,
   int(notificationTimeout),
   notificationIcon
))

To do this, you have to first unzip the zip file into a directory, then edit the file ‘service.py’, and then zip the directory again, and put the zipped thing back where you can load it from kodi (with install from zip file).