jessehamner / WeatherWidget

Python and Shell scripts to get radar and hazardous weather outlook info, plus local conditions, from the NWS API. New RIDGE II radar compatibility coming soon.
Apache License 2.0
5 stars 0 forks source link
geektool goes16 national-weather-service noaa nws nws-api python radar-images tabler weather

Weather Widget

A small set of python and bash utilities to retrieve radar images and the text of the Hazardous Weather Outlook for a given region from the US National Weather Service. On Mac OS X, these scripts integrate nicely with GeekTool desktop widgets. On linux, these resources can be nicely incorporated to a tabler (based on Angular.js) dashboard/webpage.

Prerequisites

Python, and either bash or zsh. I have no idea if this works on the Windows 10 bash interpreter. ImageMagick is also required. This codebase is generally intended for Mac OS X and Linux, but obviously there are Windows versions of all of this software, but I don't regularly use Windows. Erik Flowers's weather icons

Quick Start

Python

The codebase has a library of functions, classes, and methods, held together with some glue in main(). For locations other than Fort Worth / DFW, the end-user will need to change numerous abbreviations in the YaML settings file, including: one for the weather forecast office, one for the radar station , and one for the local conditions station abbreviation.

More recently, functions have been added to gather forecast information from the NWS web API

and hydrologic information from the NWS Advanced Hydrologic Prediction Service.

The YAML settings file does require a lot of abbreviations and such, but it's all pretty well contained in that one file. (Exception: merge_backgrounds.sh still hasn't been adapted for the settings file)

Basic program flow:

Python

bash

Limitations

The National Weather Service API currently lists only one endpoint as valid, the https://api.weather.gov/alerts endpoint. As of this writing, the "current observations" also works, though I do not know if the coverage is universal.

Setting Up Scheduled Jobs

Mac OS X

Before the first run, the end-user must modify the plist. There are sensible defaults but the path to the scripts must be set before it can run successfully.

Troubleshooting note: I found that the scripts don't necessarily have access to a PATH variable -- meaning the absolute paths must be specified for everything.

Put the getweather.plist file into ~/Library/LaunchAgents/

If you have already done this once, you may need to unload the plist first.

launchctl unload ~/Library/LaunchAgents/getweather.plist

launchctl load ~/Library/LaunchAgents/getweather.plist

To use GeekTool, one must also set up a widget ("geeklet").

Linux

Add a line to /etc/crontab and be sure that the end of the file contains a blank line, or else the last line of the file won't be parsed. The line might look like this (though using root is a terrible idea and that's an issue I will fix):

# Get weather radar a minute after the image is scheduled to appear:
3,6,10,15,19,23,27,35,38,43,47,51,55,59 * * * * root  /opt/weatherwidget/getweather.sh

That other Geeklet

In case you're curious (one person was) about the "Time Zones" geeklet seen in the desktop screencap, the bash command is this:

echo "Mtn View:   $(env TZ=America/Los_Angeles date +'%l:%M %p %A')";echo "Dallas:     $(env TZ=America/Chicago date +'%l:%M %p %A')";echo "Boston:     $(env TZ=America/New_York date +'%l:%M %p %A')";echo "London:     $(env TZ=Europe/London date +'%l:%M %p %A')";echo "Amsterdam:  $(env TZ=Europe/Amsterdam date +'%l:%M %p %A')";echo "Banglalore: $(env TZ=Asia/Kolkata date +'%l:%M %p %A')"