I like to have the Caller ID of my calling system displayed on XBMC and my music system. I wanted an easy way to do this without having to change any dialplan code. The best option is to use curl. Trixbox will hit an html page of your choice and pass the callerID on the URL. This works great. You can have a php script that does whatever you want.
First install the dialplan injection module. This module allows you to insert bit’s of Asterisk dialplan into your PBXconfig call flows.
WARNING: Dialplan Injection bypasses many of the safety checks of PBXconfig. It is very easy to screw up your system using this module. If you add a Dialplan Injection to your system and anything strange happens please remove and test again. Even if the problem doesn't seem to be related.
Next go to PBX settings -> Setup -> Advanced-Dialplan Injection and select add Injection
Give it a description like "CallerID"
For the destination pick where your incoming call normally go. For example if you inbound route sends calls to "Ring Group 1" then make the destination for this injection "Ring Group 1" later you will change the inbound route to point the injection. Effectively routing the call through the injection and on to the rest of your call flow.
Next hit submit. Then click on the injection you just created. Now you can enter your dialplan.
For this project you will only need one line of code.
Set(CallerIDError=${CURL(http://192.168.1.100/callerid.php,name=${CALLERID(name)}&number=${CALLERID(number)})})
CallerIDError is an arbitrary variable the holds the result of the call.
The URL is the location of your home automation script. It can be on your trixbox or on another box.
Next hit submit and reload. That it! You are now sending CallerID to your script.
Here is the PHP code I use to send callerID to XBMC
$name = $_POST["name"];
$number = $_POST["number"];
$httpname = str_replace(" ", "%20", $name);
$out = $httpname." ".$number;
exec("callerid.sh ".$out);
$out = date('F Y h:i:s A')." ".$number;
// Debug
//exec("echo '".$out."' >> /var/tmp/callerid.log");
?>
This strips the URL encoding and send the info to a bash script. The bash script has this in it.
IPADDR=`$IFCONFIG eth0|gawk '/inet addr/{print $2}'|gawk -F: '{print $2}'`
curl http://192.168.1.100/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.Notification($1,$2,1000,c:\temp\phone.png)
That’s it. Have fun!
Please see http://www.trixbox.org/forums/trixbox-forums/help/caller-id-displ... for an alternate version, which you can implement from the Trixbox Web UI, without PHP or CURL.
- Post 5 has my final working plan and code, whereas the earlier posts contain some more information that I found on how to customise you CID being displayed on your XBMC.
Nice work andrew.