So this weekend I decided it was time to resurrect some of the old caller-id scripts I used to utilise. Previously I had used YAC as my caller-id server and listener on a windows pc, and used a python script on XBMC to display the caller ID on the old xboxes I used as media centres.Due to the latest version of XBMC (EDEN) the older scripts no longer function. The next problem is I no longer use a windows machine anywhere near a telephone point. There is however a linux server running right next to a telephone point I could hook an old external modem to and utilise that way.
After some research online, I found there was a package called NCID (network caller-id) that would happily monitor the responses from a serial modem and broadcast the caller-id information around my network.
In the interest of squeezing every last bit of usage from my new iPhone I also decided I needed to be able to send CID info to my phone via something like growl etc.
So now that we know all that, the software want list looks like this:
- Ubuntu Linux Box
- Windows YAC listener
- Some kind of push notification app for the iPhone
- NCID client for OSX so we can see the popup info on our Macbook
- A python script to install on the Apple TV’s I have replaced old xboxes with.
So for the Ubuntu linux box – That’s already setup and working as an sql server for sharing the media database between multiple xbmc clients
- We also need a serial modem that supports Caller-ID AT Commands.. Just so happens I have a netcomm roadster (Used to be US Robotics)
Windows YAC client is easy. We simply download the package from: http://sunflowerhead.com/software/yac/
Push notifications to the iPhone was a little more complex. Originally I was going to use Prowl and have the ubuntu box push the information out using that. However being a “thrifty” fellow (RE: TIGHTARSE) I decided to use boxcar as my app of choice. For those that don’t know, boxcar is used to push a number of different notifications to your iPhone via push messaging. Things like twitter updates, Facebook, and all sorts of other services. The beauty of box car is you can setup your own “Service” using their API and have custom icons etc assigned to that service. Otherwise you can simply do it with your own username and password, and skip the pretty icons. Boxcar will interpret your messages as Growl notifications and still display them on your iPhone. You can read more about boxcar and get the app from: http://boxcar.io/
Finally a way to push the information to XBMC running on any platform. xbmc now ships with a command called “xbmc-send” which can be used to send JSON-RPC commands to XBMC clients on your network. Rather than re-invent the wheel I decided to use this as a way to popup the notification box that displays the CID information. On the main AppleTV i’ve also used that same command to pause the video on an incoming call.
So lets finally get down to business.
Download the Yac client from the above listed website, and install it on your windows machine.
Once install head over to your start menu and run the Yac Listener application.
At this point, if you right click and drag the listener app from the yac item of your start menu into the startup item, the listener will run each time windows start up and you’re logged in.
Ubuntu Server Setup
First we need to download the ncid package. For me, this wasn’t already available from the repo’s I had setup, so i had to setup repos using the following commands:
wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu precise-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'
once thats done we run:
sudo apt-get update
sudo apt-get install ncid
This will install both the ncid Server and the ncid-client which we will need to send info to xbmc and to our iPhone.
The next step is to configure NCID to actually utilise the modem.
next we enter:
sudo nano /etc/ncid/ncidd.conf
Search (CTRL+W) for the line that states:
# Set noserial = 1
and change it to
Set noserial = 0
Save the file (CTRL+O) and then exit nano (CTRL+X)
Now we need to edit the ncidmodules.conf file to send cid info to our yac listeners
sudo nano /etc/ncid/ncidmodules.conf
Search for YACLIST=”127.0.0.1″ and change it to the ip address of your windows computer. IE: YACLIST=”192.168.0.XXX”
Save and close this file as we’re now done with it.
Next we need to create a script that will handle the notifications for us. I decided to add all my custom notifiers into the one file, however you could launch separate processes for each notification (Now that I think of it, I’ll try that next :D)
sudo nano /etc/ncid/ncid-prowl
Copy and paste the following in as your script
# ncid-prowl output module
# Modify as needed for new module
# kiip "ncid-" in the name
# input is 5 lines obtained from ncid
# input: DATEnTIMEnNUMBERnNAMEnLINEn #
# input is 5 lines if a message was sent
# input: nnnMESSAGEnn
# Message will be in $CIDNAME#
# ncid usage:
# ncid --nogui [--message] --program ncid-prowl
[-f $ConfigFile ] && .$ConfigFile
# Test to see if the number has an alias assigned to it - or if ncid is unaware who owns this number
# If there is an alias assigned - push this value to the T1 variable, otherwise set T1 to the number of the incomming call
if [ "$CIDNAME" = "NO NAME" ];
# Send notifications to XBMC #
# Send notification without pausing currently playing item - Uncomment if you dont want a pause
# xbmc-send --host=IPOFXMBC -a "Notification(Incomming Call,Call From $T1)"
# Send noticiation and PAUSE the currently playing item - Comment if you dont want a pause
xbmc-send --host=IPOFXBMC -a "Pause"
xbmc-send --host=IPOFXBMC -a "Notification(Incomming Call,Call From $T1)"
# Send noticiations to boxcar #
# Replace UN with your boxcar username(email address)
# Replace PA with your boxcar password
/usr/bin/curl -d "notification[from_screen_name]=Incoming Call" -d "notification[message]=Call From: $T1" -user "un:pa" <a href="https://boxcar.io/notifications">https://boxcar.io/notifications</a>
Save and close nano with this new script
next we make it executable
sudo chmod +x /etc/ncid/ncid-prowl
Now that we’ve got all that setup we need to set the ncid client and the ncidd daemon to start on startup
sudo update-rc.d ncidd defaults
now to create a scrip that will start ncid and push the notifications to our ncid-prowl script.
sudo nano /etc/init.d/start-ncid.sh
ncid --no-gui --program /etc/ncid/ncid-prowl &
Save and close the script
now we need to make it executable
sudo chmod +x /etc/init.d/start-ncid.sh[/code[
then add it to the default startup items
sudo update-rc.d start-ncid.sh defaults
reboot the box with
sudo shutdown -r now
and on reboot your caller id should be working without a problem
if you want to have peoples names appear instead of simply their numbers (For known callers) simply edit the file /etc/ncid/ncidd.alias file and follow the comments in the file.
To have the notifications sent to your mac download and install a program called NCIDPop. Don't bother turning on growl notifications as they don't work with the latest version of growl.
So after all that.. you finally have NCID setup and sending Caller-ID info to as many devices as possible. And all for free 😀
UPDATE: After mucking around with this some more, I decided to go ahead and split the xbmc and boxcar notifications into different scripts.
The advantage of this is that now my iphone is alerted at almost the exact same time as xbmc. So in the interest of speed I created a second script. All thats required is to copy the entire ncid-prowl script and edit it a little to remove the xbmc notification part. We do the same for ncid-prowl by removing the boxcar part
sudo cp /etc/ncid/ncid-prowl /etc/ncid/ncid-boxcar
sudo nano /etc/ncid/ncid-prowl
Delete the lines related to boxcar notifications then close and save this file
sudo nano /etc/ncid/ncid-boxcar
Delete the lines related to xbmc notifications, then close and save this file.
Make the ncid-boxcar script executable (I think it already is as we copied it, however just in case)
sudo chmod +x /etc/ncid/ncid-boxcar
next we need to update the /etc/init.d/start-ncid.sh script file to run a second instance of ncid. From the documentation it's stated we can run as many instances of ncid as we like/require so we simply add another line to enable our boxcar script
sudo nano /etc/init.d/start-ncid.sh
add the following line under the first line that starts our xbmc script:
ncid --no-gui --program /etc/ncid/ncid-boxcar &
close and save this file and kill any running ncid processes
sudo ps -aux |grep ncid
once you identify the process ID for the running ncid issue
sudo kill -9 PROCESSNUMBER
And enjoy your multiple instant alerts.
Next I'll look at integrating this into the main ncidd script. Its already doing it for ncid-yac so I dont see why it can't run our scripts as well.
For those that want to do the same thing without the linux box and using windows to send to their xbmc machines (Thats any box running a current version of xbmc from Dharma up)
- Download and install YAC Server from http://sunflowerhead.com/software/yac/yac-0.16-win32.zip
- Once thats installed download this file: http://www.endpoint.eclipse.co.uk/wordpress/yac-0.17-win32.zip
- Extract that zip file to the same folder as your YAC installation and overwrite any files. I pulled this file from here: http://mattcollinge.wordpress.com/2007/05/18/spoken-caller-id-using-yac/
- Download and install WGET into C:\windows\system32 or anywhere else in your command path. http://gnuwin32.sourceforge.net/packages/wget.htm
- Edit the Yac-helper.cmd file to the following:
rem Helper Script for YAC 0.17.
present in the same
rem folder as
this will be run each time a call is
rem received. The type of data being passed through
rem in %2 & %3 is specified in %1.
rem %1 = ( call | message )
rem %2 = either the calling number or text-based message
rem %3 = the calling name (not set for a text-based message)
rem This next line simply passes the parameters on to a piece of VBScript. But you can
rem modify this line to call any app you like :)
Edit line 19's username/password to match what you have setup in xbmc, and ensure you enable all the options in xbmc network services. Not only will this help this script to work, but lets you do some pretty funky stuff with your xbmc machine 😀
You can also use the same principal to adapt the boxcar notification stuff into windows as well.
I haven't been able to test this script as I dont have a windows machine thats running yac server. Give it a go and if it doesn't work I'm happy to take suggestions that do make it work.
There is another solution to this though: http://forum.xbmc.org/showthread.php?tid=105931 There they edit the .vbs script and make changes in there to get things happening. In saying that, I don't see the point to do this when the solution is so elegantly simple
So there you have it, a linux and windows solution. AND YES YOU CAN DO IT ON A MAC.. you'd use NCID and automater.