How To : CallerID display on MythDora from FreePBX / Asterisk
After spending countless hours trying to put together the the right way to display Caller ID info onscreen on my MythDora frontends I finally accomplished it. In an effort to save others the same amount of trial and error I am documenting how this is accomplished. Sort of a payback for all the help I have received from others over the years. The steps are all from various online sources and I give full credit to those that have put together the individual steps. What I have done that I could not find anywhere was a comprehensive sequence to follow especially for MythDora. As always YMMV but the WAF I have received after just a few days has been well worth it.
For those who don't know, Asterisk is a VOIP telephone systems that is run on linux and is free just like MythTV. It can be used to connect your local intranet directly to a VOIP provider thereby elimimnating AT&T. The number of features is fantastic and it can be run from a relatively low powered computer. It is kind of like Vonage but without the proprietory software or hardware. While you can connect up regular analog telephones using adaptors between the computer and the phone these can be a little pricey. If you replace your analog phones with VoIP phones then no additional harware is required. I am using IP phones by Cisco in my home and one of the best features is whole house hands-free intercom. FreePBX is a web enabled GUI for Asterisk and has replaced the previous version called Asterisk@Home. A one touch installation is contained in "PBX in a Flash" (PiaF) which, like MythDora consists of a bootable CD image which loads Centos OS and a host of other apps to make a simple and functional FreePBX deployment. For more details see the PiaF website. For CallerID, VoIP is nice because the information is immediately available when the phone starts ringing unlike traditional POTS callerID which usually have a delay until the second ring.
For my setup I am using PiaF ver 1.4 and MythDora 10.21. Both the Piaf and MythDora backend are on dedeicated machiones and I have multiple separate MythDora frontends. This assumes you have MythDora installed and running and FreePBX installed and operational. you also need to have a Ring Goup setup in FeePBX.
Lets start by setting up FreePBX to send the CallerID to the individual frontends. We will configure the frontends later.
First sign into your FreePBX Administrative webpage.
Under Tools tab> System Administration > Custom Destinations
Click "Add Custom Destination"
For Custom Destination type "custom-callerID,s,1"
For Description type "CallerID to MythTV"
For Notes type nothing or anything you want
Click "Submit Changes"
Switch to Setup tab > Internal Options & Configurations > Misc Applications
Click "Add Misc Application"
For Decription type "MythTVCallerID"
For Feature Code, type any combination of numbers not currently being used for extensions or features. In my case I used "7890".
For Feature Status "enabled" (I think this is default)
For Destination at the bottom of the page there should be a Custom Destination drop down box which should contain you new "CallerID to MythTV" destination. Click that option.
Click "Submit Changes" button
Click the orange "Apply Configuration Changes" button at the top of the page.follow that by clicking the "Continue with Reload" option on the popup screen.
Go back to the Tools tab > maintenance > Config Edit
Using the /etc/asterisk group list (I think this is the default group) find and click on "extensions_custom.conf". Scroll down to the end of the file and add the following:
[custom-callerID]
;
; Call FreePBX macro to set CALLERID(name) to caller's identity
;
exten => s,1,Macro(user-callerid)
;
; The following section is optional...
;
; Rewrite the numeric string to include hyphens
;
; Examples: 2345678 -> 234-5678
; 12345678 -> 1-234-5678
; 2345678901 -> 234-567-8901
; 12345678901 -> 1-234-567-8901
;
exten => s,n,Set(len=$[${LEN(${CALLERID(num)})}])
exten => s,n,GotoIf($[${len} < 7]?send)
exten => s,n,Set(CALLERID(num)=${CALLERID(num):0:$[${len}-4]}-${CALLERID(num):$[${len}-4]:${len}})
exten => s,n,GotoIf($[${len} < 8]?send)
exten => s,n,Set(CALLERID(num)=${CALLERID(num):0:$[${len}-7]}-${CALLERID(num):$[${len}-7]:$[${len}+1]})
exten => s,n,GotoIf($[${len} < 11]?send)
exten => s,n,Set(CALLERID(num)=${CALLERID(num):0:$[${len}-10]}-${CALLERID(num):$[${len}-10]:$[${len}+3]});
; Send a formatted string to MythTV using netcat (nc)
;
exten => s,n,System(/bin/echo -n -e "@CALL${CALLERID(name)}~${CALLERID(num)}" | nc -w 1 192.168.X.X 10629)
NOTE: Due to this web page formatting the above code has some single lines that have been broken into 2 lines. Every actual new line starts with "exten =>"
Substitute the IP address for your target MythFrontend machine for the "192.168.X.X" shown. For more than 1 target frontend you add a new line exactly as above with the different target IP address. My configuration file has 6 separate lines for my different targets.
next, click "Update" button at the bottom of the page
Go back to Setup tab > Inbound Call Control > Ring Groups
To your new or existing Ring Group that will be activated with each inbound call add the extension "7890#" or whatever Feature Code number you used when you added the Misc Application above. Note that you need to include a "#" at the end of the number. Click "Submit Changes" button and orange "Apply Configuration Changes" bar and "Continue with Reload" on popup screen.
Now you need to restart Asterisk. I'm not sure the best way to do this so I went to a SSH screen and using admin privaleges typed "amportal restart". That concludes the FreePBX portion.
At this point your FreePBX/Asterisk will broadcast the caller ID information to the LAN addresses you specified earlier. Next, we need to get the MythDora frontends to receive that information and display it. For that, MythTV comes with MythNotify which displays information when MythTV is playing recorded programs or videos. But I wanted to display the callerID info even if I was browsing available programs or using different MythAddons. For that we need to use xyac. This program combines xosd and a listener for broadcasted callerID information.
On each frontend:
First you need to make sure the 10629 port is open. I am sure there must be a way to do this better but I decided that I did not need iptables firewall service on these frontends because none of them communicates with the outside. I disabled the firewall on each of these by typing at the command prompt
#service iptables stop
and kept it from restarting at boot with
#chkconfig iptables off
next we need to download and install xyac and its dependency files
#yum install xosd xosd-devel
and the following series of commands:
#wget http://bah.org/tivo/xyac/xyac-0.1.tar.gz
#gunzip xyac-0.1.tar.gz
#tar -xvf xyac-0.1.tar
#cd xyac-0.1
#make
#make install
if you get a
make:gcc:command not found
error you need to run
#yum install gcc
than try "make" and "make install" again
After completing this, xyac is installed in the /usr/local/bin folder
Now you need to get xyac started during the frontend boot. What worked for me was to place a call to the xyac program in the startup file for Mythdora. You could create a file to start xyac and place it in the ~/.kde/Autostart folder, but that does work if your desktop environment is Gnome. By adding the xyac startup line in /usr/share/mythdora/mythfontend.sh the xyac is started regardless of desktop environment but will need to be added again if mythfrontend.sh ever gets overwritten (maybe during an upgrade?).
I added the following line just below the PATH line in mythfrontend.sh
/usr/local/bin/xyac –c yellow –A center –f –adobe-helvetica-bold-r-normal-*-*-240-100-100-p-*-iso9959-1 –o 100 –s 5 –d 10
This needs to be all on one line. The -A option determines the horizontal location of the message (left, center, right), the -o option is the vertical offset from the top of the screen (lower number puts the message closer to the top). The -s option is a drop shadow, and the -d option is the duration of the displayed message in seconds. There are a few other options as well which are documented by typing at the command prompt
#xyac --help
Once mythfrontend.sh has been modified and saved you can restart the myhtfrontend and check that xyac is loaded by typing at the command promt
#ps aux | grep xyac
You should see something like this
mythtv 12169 0.0 0.0 13468 1344 ? Sl 01:33 0:00 /usr/local/bin/ xyac -c yellow -A center -f -adobe-helvetica-bold-r-normal-*-*-240-100-100-p-*-i so8859-1 -o 100 -s 5 -d 15
root 32178 0.0 0.0 4044 672 pts/1 R+ 14:22 0:00 grep xyac
If you only see the "root ..... grep xyac" line there is something wrong.
Now you should be able to test the frontend by issuing the following from a command prompt on the FreePBX box:
#echo -n -e "test" | nc -w 1 192.168.X.X 10629
where you substitute the IP address for your frontend for the 192.168.X.X .
If that works you just need to wait for the phone to ring!

MInor Updates
Great info. I did have a few issues.
1) I think you need to add the (send) label to the System call line (http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIf).
exten => s,n(send),System(/bin/echo -n -e "@CALL${CALLERID(name)}~${CALLERID(num)}" | nc -w 1 192.168.1.202 10629)
Without it, my /etc/asterisks/full log shows this error and no caller id info was displayed:
[2009-11-24 21:46:06] NOTICE[23977] pbx.c: No such label 'send' in extension 's' in context 'custom-callerID'
[2009-11-24 21:46:06] WARNING[23977] pbx.c: Priority 'send' must be a number > 0, or valid label
2) Also the "amportal restart" command was not causing my system to reread the config file. I used this which caused an update:
asterisk -vvvvvr
and then "restart gracefully" w/in the asterisk CLI
3) one must install the Custom Destination module
Also my post here (http://pbxinaflash.com/forum/showthread.php?p=36996#post36996) indicated that superfecta (http://projects.colsolgrp.net/wiki/superfecta) might be used here.
Hope this helps others.
Mike
Thank you for the corrections
Mike,
Thanks for the corrections.
It sounds like you might have missed including the line
exten => s,1,Macro(user-callerID) (5th line from the top) when you created the [custom-callerID] section of extensions_custom.conf. That would explain the error messages you were getting.
Your other corrections are very helpful. Unfortuneatly the original post apparently cannot be edited. If any of the moderators see this .. please make the corrections in the original post if you can for items 2) and 3) from Mikes post. Thanks
Robert
Not sure
Robert,
Not sure, but I did have that line there. Either way it works now. Your original post was a great help.
Mike
Woops. Replied in the wrong
Woops. Replied in the wrong place
Of course MythPhone has
Of course MythPhone has already been removed from 0.22 as of last Winter but I do believe Mythnotify as you used here remains intact.
The posted configuration
The posted configuration does not involve MythPhone or even MythNotify. The problem with MythNotify is that it provides onscreen display ONLY when MythTV is in program replay or video play mode. So if the phone rings while you are scanning the list of recorded programs in MythTV, no CallerID info will appear!
The above method bypasses this limitation of MythNotify by using XYAC to provide on-screen display. Although I have set it up to start from within the mythfrontend startup script, it can be started without mythtv and can even be used to display CallerID on a non MythTV linux box.
Robert
Even better that it is
Even better that it is independent. I stand corrected here.
BTW, your config looks great in Opera 10, the config text is colored so it stands out, normal text from the post is black and white. This needs to be saved in tips n' tricks if you ask me.
Glad it worked
Even better that it is independent. I stand corrected here.
BTW, your config looks great in Opera 10, the config text is colored so it stands out, normal text from the post is black and white. This needs to be saved in tips n' tricks if you ask me.
Glad to hear this worked well for you. It would be great if this could be moved to Tips n' Tricks