scribble

The Flying Developer

Home About Me Twitter GitHub Contact

30 Jan 2012
Geckoboard Weather Widget (Wot I Made)

Earlier this week I came across Geckoboard, a neat app that allows you to create Panic-like status boards to monitor all sorts of interesting stats.

I decided I wanted to use it to create a living room dashboard that pulls in my calendar events, the current time, the weather, and maybe a todo/shopping list. I would then place my iPad somewhere prominent and have all the info available at a glance.

Mixing Business and Pleasure

Unfortunately for me, most of Geckoboard’s built in widgets are integrations with business oriented services: Github, Basecamp, Pingdom, that sort of thing. Whilst these would look great in an office lobby, I don’t think my wife would appreciate live uptime stats in our living room. Time to improvise!

Geckoboard has this concept of custom widgets which allows you to shoehorn any data you can get your hands on into various predefined templates for display. There are a range of different chart types available, as well as maps, numerical displays, and plain text.

I decided I was going to get my feet wet by creating a weather widget that would display the current temperature along with the conditions. This would be represented in a custom plain text widget.

Sourcing the weather data turned out to be really easy. Yahoo has a fantastic weather API which is free to use for non-commercial purposes that works by simply sending a request with your location to a particular endpoint. The hardest part (which is still dead simple) is looking up your ‘WOEID’ (short for Where On Earth ID), a numeric ID for your location.

WOE Is Me

With my WOEID in hand, it was time to wrangle the data. I created a new Rails project with a simple endpoint that took an ID and spat out the weather data for that location. With a little help from the xml-simple gem I then refined the response to include only the data I needed (The temperature and the condition text) before re-wrapping the response in json to be returned. This was maybe half a dozen lines of code in my controller. In fact, Rails is probably way over the top for something like this but it’s what I have the most experience with so I went with it anyway.

I created an app on Heroku to host everything, and then tried it out. Here’s what the widget looks like (excuse the boring Ottawa weather):

Really simple, but exactly what I wanted. I liked it so much that I decided to share it. Head over to the app on Heroku for instructions on how to use it yourself: Gecko-Weather.

I’m planning on adding a couple of extra features soon, namely the ability to specify Fahrenheit/Celsius and some error handling in case the weather info is unavailable for some reason. I’m also open to suggestions, so please post any requests in the comments!


Thanks for reading! If you like my writing, you may be interested in my book: Healthy Webhook Consumption with Rails

David at 10:00

scribble

Home About Me Twitter GitHub Contact