What’s the deal with weather?

It’s funny that as nerds, we probably have more weather apps on our desktops than actually going outside or looking out a window. I admit I do it myself. On the laptop I have the Enlightenment Weather Module loaded up, as well as ForeCastFox on all of my desktops and laptop with continual popup reminders letting me know down to the minute barometer pressure and current ceiling height.

All facts that I absolutely desperately need to know, now!.

So, being the enlightened asterisk user I am, I decided to search about and find what I could about making a cool little extension to call up my asterisk server and deliver me the weather for my local city of Ottawa, Canada.

I noticed that there seems to be a flurry of chatter going on lately on sites such as Nerd Vittles and SineApps about weather scripts. Most of these use free software such as Festival or the Voice Synthesizer. However, I have a license for this wonderful product called Cepstral. I decided I wanted to use Cepstral because I prefer the voice quality to that of the free ones, and it was only like 30 bucks to register.

So, what you’ll find below is a very quick and dirty hack of what I found already available, but instead to use Cepstral to play back the weather on your home system:

  1. Note this is for a Stock Asterisk Installation, no FreePBX or AAH or AMP or any of that GUI stuff.
  2. Note this also assumes you have cepstral integrated. If not Follow this howto.
  3. Then you’ll want to install Asterisk::AGI Perl Module using CPAN or downloading it manually and installing it.
  4. Now you’re going to want to create the AGI. I found a similar copy to this one on Nerd Vittles, and modified it for my use with Cepstral.
  5. Edit /var/lib/asterisk/agi-bin/weather.agi, and make the contents be the following: Get the modified Cepstral Weather AGI here
  6. Then you’re going to want to give the file the proper permissions
chown asterisk:asterisk /var/lib/asterisk/agi-bin/weather.agi
chmod +x /var/lib/asterisk/agi-bin/weather.agi
chmod 755 /var/lib/asterisk/agi-bin/weather.agi
  1. Then you want to download the weatherscript from Nerd Vittles.
wget "http://www.offshack.com/astweather/weatherscript" -O /usr/local/bin/weatherscript
chmod +x /usr/local/bin/weatherscript
  1. Now edit your asterisk extensions to include this somewhere proper (outside menu? common extensions? etc)
; weather script  
exten => 7601,1,Answer  
exten => 7601,2,AGI(weather.agi)  
exten => 7601,3,Hangup
  1. Reload Asterisk
  2. Call 7601 to verify that it reads your weather
  3. Now just create a cronjob to run /usr/local/bin/weatherscript every hour, and you’re set!