Tuesday, March 3, 2015

A Change in Direction

One nice thing about being independent is the capability to do something different when you decide to.  Since I've reached a bit of an impasse with the spam filter, I'll play with another task I've been banging around with for a while.

But first some background information, and a short introduction to amateur meteorology. 

For the past 20 years or so I've been tracking the weather a little bit closer than most people.  In the back yard on a heavy metal stand is a weather station, which allows me to see the conditions in my yard at pretty much any time.  This is a Davis system (http://www.davisnet.com/), which consists of the outdoor component, which measures rainfall, temperature, wind, solar conditions, and so forth, and an indoor base station that records and displays the measurements.  This isn't my first station, though.  I have worked my way thorugh a system from Oregon Scientific (http://www.oregonscientific.com/us/) which did essentially the same thing.  I switched about 9 years ago when I was changing servers around, and the new one had no serial ports.  Oregon Scientific at the time only supported serial communications, while the Davis system supported USB.

Now this information os good, but gets really useful if you can pull it up on your web browser, or in an app on your phone.  For that I have been transmitting this data to the Weather Underground (http://www.wunderground.com/) for pretty much all of that time.  You can see my particular weather station at http://www.wunderground.com/personal-weather-station/dashboard?ID=KTXMCKIN31

Now there are plenty of ways to get this information from a base station uploaded.  There are software packages that you can run on a laptop, from Ambient and Davis.  These are nice, customizable, and sort of supported.  I had been doing that until last summer, when the laptop I was using as a server started having problems, and being unable to move the software easily to another laptop, I started looking at other options.

In the past few years the concept of a network appliance has cropped up.  this is usually a little device running Linux or some other lightweight operating system, usually with a few ports, powered by a 5 volt source, WiFi, powered by a very common 5 volt power source, and geared towards a single application.  As I was searching for replacement software I stumbled across a number of weather appliances that were capable of supporting most of the consumer weather stations out there.  After researching them a bit, I went with the Meteobridge unit (http://www.meteobridge.com/wiki/index.php/Main_Page).  I was able to get it running in a couple of hours, setting up the base station, Wunderground push, WiFi, and other items, and decommission the old laptop.

The Meteobridge acts as a bridge between your weather station and most of the weather services out there.  It is capable of communicating over USB (or even ethernet) to your weather station, and then pushing this data to all of the services you wish to push it to.  It also has its own web interface that allow you to configure and monitor it.

Now one of the things it is capable of doing is to FTP the data to another location.  It makes use of a template that you supply and stores the data at a location that you can specify.

So quite a while back I created a template and got it set up to store the data on an FTP folder on a laptop in the house.  I haven't really had time to do anything else with this since then - at least until now.

So what I'm planning on doing is to make use of this data.  broadcast the information out on Facebook, Twitter, or whatever, update web sites, send out alerts, and generally be a communications hub for exporting this data.  Now you might ask, "Doesn't the Meteobridge applicance already do this?", and the answer is "sort of".  It will fire off twitter messages, and email things based on some conditions or periodically, but that is about it.  it is real good about talking to weather services, but not so well on the social scene.  Think of the meteobridge device as a weather nerd.

So what do I want to do with this?

Fire off emails when conditions warrant it
tweet about weather in the area
post to facebook periodically
update a web site with the information

So I started creating a base application this afternoon.  I already had my template, and it was working fine.  An hour spent in Visual Studio got me enough scaffolding to read the incoming data (dumped conveniently in an XML file) and toss it into a database.

So now what?

First I'm going to figure out the rules part.  given the current information, I would like to determine if a message should be sent.  a rules engine of some sort will be needed. 

Now there are three ways to handle rules.  The first is to hard code the rules, and compile it into the application.  I'm against this because every time you want to do something different you'll have to rebuild the entire application.  It also precludes being able to distribute the application and make it useful to others in any meaningful way, since what they might consider as important to send an email about won't even show up on your radar.

Second is some sort of database to hold the rules, with numerous tables and fields containing the data for the various rules.  While this is more flexible than the previous, it doesn't allow someone to deviate too far off the reservation.  No complex rules, no deviation from the patterns already set.

the final way is to use a rules engine.  Essentially what a rules engine is is a library that can parse a set of rules, and then run the rules on the incoming data, firing off if one of the rules triggers.  Now this cold be done by hooking into the current compiler, but that is overkill.  instead I'll make use of the rules engine within the Windows Workflow Foundation.  This will allow me to look at the data and act upon it as needed.

Communication is next.  I'll need ways to communicate with the various social applications out there in some meaningful way.  Most of them have interfaces that are published, so that should not be too hard.  Email is also a solved problem, and will just be a matter ot working with a library to get things out there.

I'll need a user interface of some sort to manage the rules, and possibly the rest of the system parameters.  I don't know the format of this right now, but it could be a Webforms project, WPF, web based, or some combination or permutation of the above.  

Finally, I'd like a web front end to display the data on, though this isn't really needed.  I can always get to the latest data on Wunderground, but sometimes you want to see slightly rawer data.

So thats it for now.  As I creat this thing I'll drop my observations in here, and once it get it into a more usable condition I'll put it up on one of the open source repositories.






No comments:

Post a Comment