/nws-alerts-m2x

Monitor weather alerts from the National Weather Service and update affected M2X devices.

Primary LanguagePythonOtherNOASSERTION

National Weather Service Alerts to M2X

NWS Alerts to M2X Logo

This application checks for new weather alerts from the National Weather Service and updates affected M2X devices by sending a Command to the devices and also by updating streams on the device which provide a time-series log of the weather alert status, message & url.

To view the raw NWS RSS feed: http://alerts.weather.gov/cap/us.php?x=0

Architecture

NWS Alerts Architecture Diagram

Pre-Requisites

You will need to have an account on the following services:

  1. M2X: M2X is an IoT time-series data storage & device management service. The M2X developer tier account is free for up to 10 devices @ 100,000 max data points written per device/month. Should you desire more capacity you'll need to upgrade your M2X Account.
  2. Heroku: Heroku is a PaaS that enables developers to build and run applications entirely in the cloud.

FIPS6 & UGC Location Codes

The National Weather Service classifies the location of weather alerts by FIPS6 county code and/or Universal Geographic Code.

This application determines if an M2X device is affected by the weather alert based on the FIPS6 and UGC codes which should be stored in the device's metadata under keys fips6 and ugc respectively.

If you'd like FIPS6 & UGC codes to automatically update on your devices whenever the device updates it's location in M2X check out the nws-geo-m2x sample app.

Installation

Deploying your application

Click the Heroku button to deploy your application to Heroku:

Deploy

Setup Config Variables in Heroku

Once you deploy the application to Heroku you will be prompted to supply the following environment variables:

  • M2X Master API Key: use your M2X Master API key which provides access to your M2X resources

Configure Heroku Scheduler

This app employs a worker script which you will configure to run hourly using the Heroku Scheduler add-on. To configure, head to the Heroku Dashboard for the app and add the following job via the Heroku Scheduler add-on:

python nws_alerts_m2x/worker.py

Important Note: the Heroku Scheduler has an option for running jobs at a frequency of Every 10 Minutes, Hourly or Daily. This script can run longer than 10 minutes depending on the number of new alerts and/or how many devices are being updated - thus you should choose a frequency of either Hourly or Daily, otherwise the script may be interrupted.

Issues

Feel free to report any issues you encounter with this app via GitHub

Thanks to...

  • M2X: time-series data store
  • Heroku: cloud application hosting
  • NWS Alerts: National Weather Service alerts RSS feed

LICENSE

This sample application is released under the MIT license. See LICENSE for the terms.