Working with METAR data

kwilcox

Active Member
I've been playing with this WX data for a few days and thought I would share some of my findings.

First let me say that METAR information is really useful! What would you think about being able to do these sorts of things in your automation system?

If its overcast out, enable the home light sensors 1 hour before sunset otherwise enable them a half hour before sunset.

or perhaps:

If its overcast with low cloud cover, enable the light sensors. Disable them again when the clouds lift.

Here's one that irks me:

If its time to water the lawn and its raining outside, don't do it!

Or, how about this:

If there's a tornado sighted and everyone's asleep, turn on all lights in the house and flash the master bedroom lights.

Well, METAR data is a way to help do this.

METAR data is maintained by automated weather stations at most airports. These stations generally transmit this information to airplanes. What's nice is that NOAA automatically collects this information every hour and makes it available via FTP. The METAR content itself is a string that can be parsed for interesting information. Sooo, all you have to do is fire up an FTP request for your closest METAR station Weather data then have fun with the results. Here's a link to get you started on the format of METAR data:

Metar Help

The Metar string from the example they use is from Chicago O'Hare Airport and in its raw state looks like this btw:

KORD 041656Z 19020G26KT 6SM -SHRA BKN070 12/08 A3016 RMK AO2

You can pull that Airport's current data by following this link:

ftp://tgftp.nws.noaa.gov/data/observation...ations/KORD.TXT

When you're ready to pull your own METAR data, here's a link that you can use to find the closest METAR station to your location:

http://www.faa.gov/asos/map/map.htm

Once you find your station's call letters then just insert it into the ftp link above in place of KORD.

Now, how to use this data in the above examples? I'm keying in on the WX and SKY data which would contain unique identifiers for various conditions. In the above example, this data is "-SHRA BKN070" which decodes to "light rain showers ovserved", "broken clouds at 7,000 feet". However, if you get a hit on "+FC" anywhere in the METAR string then you've got a tornado situation. While better than nothing, this data can be up to an hour old since NOAA only updates their info once per hour. Much more useful would be finding "RA" which is a rain indicator in WX data or "OVC" in SKY data. In my example above, "OVC" triggers early sensor mode and "OVC" followed by a number less than 100 triggers "sensor now" mode.

Several automation systems have a built in ability to pull METAR data which frees you up from having to program the FTP pull and import logic. I use HCA which has direct support for METAR data. Unfortunately, they don't currently decode WX or SKY data into their WeatherConditions variable. Hopefully, I'll be able to convince the tech group at Advanced Quonset to start doing this in future releases; I had suggested that they simply place the WX and SKY strings into WeatherConditions and let us parse away. Perhaps other posters can speak to their system's WX and SKY capture capabilities.

Anyway, this is pretty neat stuff and the biggest advantage of all is that its FREE! Paid for by our taxpayer dollars. Have fun with it!
 
If it were just updated more often than hourly then we would have something. This is where having someone near you uploading to Weather Underground is nice.
 
Still, SKY data is more than adaquate for the purposes of my system's nighttime mode. I'm currently manually adding the WX and SKY strings to HCA's WeatherCondition variable and have used this to fine-tune my home's lighting system. Previously, my system turned on "nighttime mode" one half hour before sunset. Nightime mode activates picture lighting, the family room lights and enables sensor control of all other upstairs lighting. the problem we had was that if it was sunny out, a half hour before sunset was fine, but things got too dark on heavily overcast days. Generally, the kind of cloud cover that reduces the light levels enough to need nighttime mode earlier doesn't form or dissipate in an hour. I've been quite happy with the results of METAR data in this respect.
 
Rupp nailed it for me. The closest airport to me is 20-25 miles away. I have a guy two miles from my house with a weather station that Weather Underground pulls from.
 
It's just parsing HTML, so I think e's write up on the subject should cover it.

www.wunderground.com is the site, and if you enter your ZIP code there, you can see if there is a person close to you with a weather station.

If you get stuck, we're all here!
 
hmmm... the only thing I don't like about html parsing is the work required when the site changes. METAR data is compelling for this reason. I was hoping that perhaps the weather underground site also had a data format portal. In some of the examples I cited, loss of weather data wouldn't be immediately noticed.
 
I have been using AWS for 2 years now, by parsing their site, and the script hasn't broken once, so it shouldn't be too hard to create a stable parser using that source. But I do believe certain other sites (weather.com?) offer an XML feed now, which should make things easier.
 
Well, you make a good point. It does change fairly regularly. The WAP site changes less, but also does not have the weather data updated as frequently, and it doesn't pull from local weather stations.

I could post my code, but I use PowerHome.
 
electron said:
I have been using AWS for 2 years now, by parsing their site, and the script hasn't broken once, so it shouldn't be too hard to create a stable parser using that source. But I do believe certain other sites (weather.com?) offer an XML feed now, which should make things easier.
E,
Can you give me an example AWS station like the one your parsing? I find AWS stations but there are dozens of pages so I was curious as to which one your parsing. TIA

Greg
 
Well, the people at Advanced Quonset seemed agreeable to placing WX and SKY data into the WeatherConditions variable, but in the meantime I developed a workaround.

Essentially, I scheduled an hourly FTP at 10 minutes past the hour to pull the METAR data from NOAA, strip CRLFs and reformat it into HCA's "get data" format. Only one non-standard utility program "LM" was used to strip out the line breaks and its a freebe.

At 15 minutes past the hour, an HCA schedule runs a program that loads the METAR string into WeatherConditions then parses it, setting flags named Overcast, Raining or Tornado based on the results. Those flags can be directly used by HCA test elements. If there's anybody out there who is using HCA that's interested, I'll post a detailed howto.

Now its off to ACE to buy a Rain Bird valve and some Garden hose adaptor parts.... I think I have a few appliance modules and a 24V transformer lying around too. :)
 
kwilcox said:
Now its off to ACE to buy a Rain Bird valve and some Garden hose adaptor parts.... I think I have a few appliance modules and a 24V transformer lying around too. :)
I did this similar setup for electron. See the next to last post in THIS thread. Obtained the parts at Home Depot (plumbing section, NOT their sprinkler section, the plastic adapter parts were way to long).
 
They sell a 24v solenoid controlled valve in plumbing? Damn, I was just at Home Cheapo looking for one but never checked out the plumbing dept. Crappity Crap... I ended up ordering the valve from ACE online for $20 delivered. It'll take 7 days though.....
 
Back
Top