Location-aware bushfire SMS alerts
I’ve put together a small Python script which can be used to subscribe to a CAP (Common Alerting Protocol) feed, analyse basic information and push it out my SMS Gateway if the alert fits certain location criteria.
You set your home location, the feed you wish to subscribe to and a distance (in Kilometres) in the script. When a new alert is delivered on the data feed, the script will determine if the alert location falls within the radius you have specified. If so, the alert topic is sent via SMS.
Of course this could be sent by any method (Push notification, email or even a phone call if you have the hardware).
Well, I find an SMS is still a good “In your face” notification method. This way, when there is an alert of interest, I receive the SMS within a few minutes prompting me to look up the full alert text.
Sure, there are other methods: Use a feed reader to process the RSS feed, monitor the Twitter account, etc. However, I find that most of these other methods require active intervention to check and process the alerts.
Currently in Australia, each state manages its own emergency services, who in turn have their own setup for disseminating information. There have been a few projects to aggregate all information, but from what I have seen none of these do quite what I am looking for.
Having said this, I actually see a great opportunity for collaboration to create a single “Australian Emergency Data Feed” (Utilising CAP-AU-STD) which can be used as a central feed consisting of the aggregated alerts from each state.### So what does it do?
Anyway, DFES in WA Publish a CAP feed (also GeoRSS, if you’re interested) to the website. We simply periodically scrape the CAP XML data feed. Once we have the XML we parse the CAP data
Then, once we have the data, we perform just two main checks on each alert contained within the feed:
- Is this a new alert (which we haven’t seen before) (id)
- Does the alert location fall within our area of interest (area: circle)
The script is aware of two things. The “Home location” (Set to the coordinates of my house) and the “Distance”. The distance is calculated between the two coordinates using the haversine formula.
If the answer is yes to both, then we extract a summary and send via email to my SMS Gateway.Now, clearly we don’t want to get spammed with an alert each time we scrape the data feed. So each time we process an alert, we store some of the information in an SQLite database. This way, further conditions can be evaluated.
- Notify if the alert is of a different severity level to the previous notification.
- Notify if the alert has a severity level of “Extreme”, regardless of previous notifications.
In practice, what this means is only one “All Clear, Advice or Watch and Act” notification will be sent. When the severity is upgrade or downgraded, a notification will also be sent.
“Emergency Warning” alerts will always be sent.