Canadian Weather
Canadian Weather
Asterisk@Home comes out of the box with *61 setup to generate weather for US cities. This is all fine and good if you life in the US, but what about up here in the Great White North? With the assistance of a post, I managed to create a workable script to generate weather from the Environment Canada website.
The process of installation is as follows:
- Save the script into /usr/lib/asterisk (or other suitable location)
- Modify it to produce weather for your Canadian City (see Environment Canada). I live in Toronto, and generated a cleaned up text file for it to run text2wave over.
- Setup a cron job to run hourly. (while you could set it to run when you type *61, the weather never updates very often and that means a 2-6 sec wait to generate the waether file - so, I opted for an offline approach)
- Modify extensions_custom.conf (for Asterisk@Home) to change it to playback the weather file.
The script is as follows:
- !/bin/sh
echo "Toronto weather for $(date +"%A %B %d, at %k %M")" > /tmp/weather2.$$
wget -O /tmp/weather.$$ -q http://text.weatheroffice.ec.gc.ca/forecast/textforecast_e.html?Bulletin=fpcn11.cwto
grep -A5 Mississ /tmp/weather.$$ | grep -v "Mississauga - Brampton." >> /tmp/weather2.$$
echo "end of forecast" >> /tmp/weather2.$$
sed "s/\.\./ /" /tmp/weather2.$$ | sed "s/km\/h/kilometers per hour/" | text2wave -o /var/lib/asterisk/sounds/weather.ulaw -otype ulaw
rm -f /tmp/weather.$$ /tmp/weather2.$$
Example extensions_custom.conf:
exten => *61,1,Answer
exten => *61,2,Playback(weather)
;exten => *61,2,AGI(weather.agi) - comment out or remove
exten => *61,3,Hangup
Created by: mbuckaway, Last modification: Mon 17 of Apr, 2006 (06:07 UTC)
Featured -
Search:

Page Changes














