Weather Alerts Through Prowl

The fun with Prowl continues.  After getting it running on my Chumby and WRT54G, I was digging through the Prowl Forums looking for other interesting applications when I found a post by acrollet showing how he has his server watch for severe weather alerts from weather.gov and send them to him as push alerts.  I thought it was a good start, but he crammed the whole thing into his cron table as one line, which is a style I just don't like, so I've rewritten his script with some improvements.

How this alert works is that every hour the cron scheduler on my alarm clock downloads a chunk of XML from weather.gov which they make available for every region across the US.  So, for example, Yolo county has the county code CAC113, so I have the script hourly download http://alerts.weather.gov/cap/wwaatmget.php?x=CAC113 and check to see if there is a new severe weather alert for Yolo county.

If there is an alert, and it's at all different from the one seen an hour ago (which the script stores in /tmp/weather.CAC113.old.txt), then the script uses some grep, awk, and tr magic to extract nice clean summaries and an event name for the alert.  It then uses the typical curl request I figured out before to fire off the push alert and it blows up my iPod with weather alerts.

One thing that you might notice about the script is that I have all of the heavy lifting done in a single function (queryWeather()), which I then call repeatedly, passing it the zone code and my API key.  I did this such that it will be very easy to add or remove zones I want to watch, as well as add friends who also have Prowl onto various zones that they're interested in (I'm toying with having this automated through a web form).

I have this installed on my Chumby's SD card (/mnt/storage/scripts/), but this should run in any decent unix environment.

Script code:

Popular Posts