Weather Underground + Mashup Hub + Pachube = orb food


The hardware side of my ambient orb project is almost finished, so I’ve been making a start at the other end: getting some data to display. Top of my wish list is to display a basic weather forecast on the orbs, which looks like it could be nice and simple thanks to the very handy Weather Underground service. There’s a decent weather station nearby for current readings, and the forecast for Southampton has been pretty accurate so far, both of which are available through the Weather Underground API.

I could process the resulting XML on my home server but, having been doing some work with mashups recently, I thought I’d create a feed mashup instead. I’ve played with Yahoo Pipes in the past but this time I created a feed using Mashup Hub on Lotus Greenhouse:

So that screen shot is probably not all that helpful in understanding what’s going on; this style of graphical programming is fairly common these days but I would personally like to see more advanced ways to document and share diagrams like this. Still, this one is pretty simple, so here’s a quick overview:

  • The path at the top extracts the current temperature from the local weather station data
  • The middle path makes use of some very handy date functions in Mashup Hub to pick out entries 12 hours ahead from the forecast data
  • The bottom path does a lookup on the forecast conditions to replace a text forecast with a numeric code

Which all ends up being published as a much simpler piece of XML. I could just grab this XML directly and process it on the Arduino, or I could save some effort and convert the mashed up XML to an even simpler comma separated list using an XML to CSV converter written for the Pachube community. Well, now it would be trivial to create a Pachube feed for the weather forecast as well… so here it is

Perhaps not the most direct route for getting a weather forecast but I think it’s a nice example of how anyone can pull together data they are interested in without any programming, or a server of their own. I’m also quite please with the results of the forecasts so far; 13 C and clear tomorrow in theory!

Advertisement

Do you want iWidgets with that?


I’ve been looking at widgets and mashups a fair bit recently and one of the questions that comes up is around what the best approach for widgets is; should a single widget do a lot, or should multiple widgets be used instead. Obviously every situation is different and there may be reasons to favour one approach over another at different times. The following example occurred to me which might show what the pros and cons are.

Say I was developing a clock widget. There are already Google gadget clocks, so it seems like a reasonable widget to want to have. I could split different parts of the clock across multiple widgets, all sending/receiving events to coordinate the display of a particular time. In the example below, there’s a widget for the hour hand, minute hand, second hand, and whether it’s the morning or afternoon. There’s nothing technically wrong with the resulting mashup – I can tell what time is being shown – but using that many widgets does not really add any value, and there’s not a lot of space left for anything else on my screen.

clock-widgets

At the other end of the scale, the example below uses a single widget to display the time. On its own, there wouldn’t be much point using a widget to show the time. It might look funky (well, if any time had been spent making the clock look better than my quick sketches) and I could move it around but you could do all that with a bit of javascript and style sheets on any old web page. Except, if the widget sends and receives events, you can use it in a mashup. There’s plenty of room for other widgets, and in this example selecting a person shows where they are located and their local time, so I know if it’s a good time to phone.

time-mashup

Obviously a clock is a pretty specific, and simplistic, example. There’s a pretty good illustration in the Enterprise Master Data Management book (Figure 2.3, page 73) which shows the two extremes in more general terms:

The first clock was modular, but it was tightly coupled; there were several pieces but only one usage.

karvajavi-puzzle

Photo (cc) Karva Javi

The second clock, and other widgets in the mashup, were modular and loosely coupled; there were several pieces and many usages.

200px-Tangram-man.svg

(Now i just need to think of an example of a widget that does too much!)

Canteen Mash


Over lunch we were discussing how it would be handy to know whether a paycut would be covered by cost savings of a shorter commute. A mushup to do the calculation for you seemed pretty doable, and you could use the same thing to find out how much money you’d save working at home a couple of days a week. Oh yes, and the environment etc.!

Well, it seems that there are at least a couple of mashups already that do part of the job. Unfortunately both these examples are a bit US-centric and don’t take in to account PAYE (so now I’m being UK centric!) but they’re a good demonstration.

I also discovered that the OS now have an API! Looking through their FAQ, they (or more likely their lawyers) have some funny ideas about how the web works, but still, better than not supporting mashups at all.