Author Topic: Weather Underground Driver  (Read 7726 times)

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Weather Underground Driver
« on: September 23, 2011, 05:07:31 pm »
I've just finished creating a driver to pull personal weather station data from the Weather Underground (www.wunderground.com).

The Weather Underground does put some restrictions on the use of their data feeds.  Please see the terms of use at http://http://www.wunderground.com/members/tos.asp#api  John, I'm not sure these restrictions would allow this driver to be included in the Elve package, but if you think it's ok, let me know and I can provide you the source under a different license.

I've only run this with Elve 1.1 so far.  I've posted the source file for the driver along with additional information on my web site at http://www.bobsplace.com/ElveWUnderground/  I'll start working on packaging up a binary with installer.

Why another weather driver?  The Weather Underground makes it pretty easy to upload data from personal weather stations. Because of this, you may be able to find a station very close to your own location and thus be able to get more accurate information.  I just installed an Acu-rite 01050C Professional Weather Station and the only way to get at it's data feed is via the Weather Underground.

Bob

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Weather Underground Driver
« Reply #1 on: September 24, 2011, 09:01:57 am »
Great! The NOAA web service is not reliable (not the driver but the web service which is outside our control) and the weather channel is trickier to set up.

Did you implement the IWeatherDriver interface?

Regarding the data feed license, I believe it is ok to include the driver in the Elve installation. The license mentions 2 important points:

A. You must give credit to the source. The driver should probably have a property which specifies Weather Underground as the source so that it is available in the same place as the data. Secondly the driver description should include a url to the data feed license so users are aware of the requirements (such as including a note on touch screen interfaces about the source).

B. Data is for personal use.  It does not indicate that the method of retrieval must be for personal use, only the data. The driver is optional as there are other weather driver choices the use of the data is up to the end user.

Please let me know if you would like to participate in the device driver incentive program. If so please review the submission section of the Device Driver Development documentation.

John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #2 on: September 24, 2011, 10:45:40 am »
Hi John,

Did you implement the IWeatherDriver interface?
I used the weather template from the SDK as the starting point and did use the iWeatherDriver interface.  It's not complaining about anything missing with Elve 1.1.  I also added a bunch of other properties and tried to be consistent with the WeatherChannel driver properties.

Here's the current list of properties:
  • Credit                  Provides credit to Weather Underground for data feed
  • DewPoint                Current dewpoint
  • HeatIndex               Current heat index
  • Humidity                Current humidity
  • Location                Location of weather station
  • Precipiation            Precipiation for today
  • BarometricPressure      Barometric pressure
  • BarometricTrend         Barometric pressure trend up/down/steady
  • BarometricUnits         Barometric pressure units
  • SolarRadiation          Solar Radiation if reported by station
  • Temperature             Current temperature
  • UVIndex                 Current UV Index
  • WindDirectionDegrees    Wind direction in degrees (numeric)
  • WindDirectionText       Wind direction (N, NW, S, etc.)
  • WindGustSpeed           Highest wind speed reported
  • WindSpeed               Current wind speed
  • Windchill               Current windchill
  • ApparentTemperature     Calculated apparent temperature (feels like)
  • LastUpdate              Last time/date that the data was reported
  • Dates                   Array of dates for forecast data
  • WeekDayTexts            Array of day names for forecast data
  • Highs                   Array of expected high temperatures
  • Lows                    Array of expected low temperatures
  • Conditions              Array of expected conditions (text)
  • DayIconIDs              Array of icon id numbers for forecast conditions
  • NightIconIDs            Array of icon id numbers for forecast conditions
  • DayDescriptions         Array of daily forecast text
  • NightDescriptions       Array of nightly forecast text
  • ConditionIconURLs       Array of URL's pointing to the condition icon
  • SmileyConditionIconURLs
  • GenericConditionIconURLs
  • OldSchoolConditionIconURLs
  • CartoonConditionIconURLs
  • MobileConditionIconURLs
  • SimpleConditionIconURLs
  • ContemporaryConditionIconURLs
  • HelenConditionIconURLs

The forecast data from this feed is not as good as the Weather Channel forecast data. There's a number of items it doesn't support (forecast wind, and precipitation for example).  They do have another API but you have to pay to use it, this is something you'd have to pay for and pass the cost on to users.  I signed up as a developer, but haven't really looked at the API yet. Plus the commercial access API doesn't provide access to the personal weather stations which is what I really wanted. So there may be an opportunity for two drivers here.

There weather icon sets are the best that I've seen either.  I tried to make it usable with other icon sets but I'll probably need to improve that some more. 

Quote
Regarding the data feed license, I believe it is ok to include the driver in the Elve installation. The license mentions 2 important points:

A. You must give credit to the source. The driver should probably have a property which specifies Weather Underground as the source so that it is available in the same place as the data. Secondly the driver description should include a url to the data feed license so users are aware of the requirements (such as including a note on touch screen interfaces about the source).
I did include a "credit" property.  maybe source is a better name for that.  The property text is currently just "Weather Underground" but it might be better if says "data provided by the Weather Underground" or something similar.  I'll check to TOS again and see if there's any recommended wording.

Quote
Please let me know if you would like to participate in the device driver incentive program. If so please review the submission section of the Device Driver Development documentation.
Sure, I'll review it again, thanks!

Bob

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Weather Underground Driver
« Reply #3 on: September 25, 2011, 09:51:37 pm »
Regarding the icons, have you taken a look at the Shiny Weather icons: http://jyrik.deviantart.com/art/Weather-Icons-Shiny-5215175

They are numbered for the weather channel... I'm not sure if Weather Underground uses the same icon numbers.
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #4 on: September 27, 2011, 08:08:43 pm »
Regarding the icons, have you taken a look at the Shiny Weather icons: http://jyrik.deviantart.com/art/Weather-Icons-Shiny-5215175

They are numbered for the weather channel... I'm not sure if Weather Underground uses the same icon numbers.

Thanks John,

I remembered see something about a nice set being available, but hadn't searched for it so you saved me some time!

Weather Underground doesn't use the numbers, they just use words to represent the conditions and then include URL's to their matching images.  I added a function to convert the words to numbers using my best guess for the right icon and then created properties to expose the numbers.  I think I still need to do some on that phrase to number routine, but other than that, it's working pretty good.

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #5 on: October 03, 2011, 05:50:09 pm »
Version 1.0 of the Weather Underground driver is now available.  I found a few problems in the first release, mostly around pulling the forecast data.  Those have been fixed.

This is specifically designed to pull data from personal weather stations created on the Weather Underground.  The goal was to get local condition data.

See http://www.bobsplace.com/ElveWUnderground/ for the download, screen shots and info.

Bob

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Weather Underground Driver
« Reply #6 on: October 03, 2011, 09:50:15 pm »
Bob, are you interested in participating in the device driver incentive program? 

Also the web page still mentions isy in the header.
John Hughes
Codecore Technologies

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Weather Underground Driver
« Reply #7 on: October 03, 2011, 11:44:12 pm »
Bob,

I took a fairly quick look at the driver (not a full driver or code review yet) and things look good. I did come up with the following mostly minor changes:

* Please add information about the required station id to the driver description.
* Add information about what a station id is and where to get the station id setting.
* Update all setting property/fields to end with "Setting" for example "StationIDSetting"... that way if you decide to expose the station id as a property you won't have a naming conflict.
* Change the following driver attributes:
   defaultInstanceName = "weather"
   deviceManufacturerName = "Weather Underground, Inc"
   deviceManufacturerUrl = "www.wunderground.com"
* The Dates property should return an array of ScriptDateTime values, not ScriptStrings. A DateTexts property can be added to return a display string for the dates.
* Instead of returning bogus values for properties which the driver does not support, please use: throw new NotSupportedException();
* The following line is a bug because there is no complementary "BarometricUnits" property in the driver:  DevicePropertyChangeNotification("BarometricUnits");
* While calling DevicePropertyChangeNotification(...) with only the property name is supported, it is recommended to also pass the primitive .net datatype value to avoid the reflection performance penalty.

* When calling DevicePropertyChangeNotification with an array, you must iterate the array, for example:

Code: [Select]
for (int i = _highs.PrimitiveLowestIndex; i <= _highs.PrimitiveHighestIndex; i++)
DevicePropertyChangeNotification("Highs", i, _highs[i]);

* Recommendation: The following 5 lines of code can be reduced down to 1 line using System.Linq. This pattern is repeated throughout the driver.
FROM:
Code: [Select]
ScriptArrayMarshalByValue array = new ScriptArrayMarshalByValue();
for (int i = 0; i < m_forecasts.Length; i++) {
array.Add(new ScriptString(IconID(m_forecasts[i].Icon).ToString()));
}
return array;

TO:
Code: [Select]
return new ScriptArrayMarshalByValue(m_forecasts.Select(f => IconID(f.Icon).ToString()), 0);
« Last Edit: October 03, 2011, 11:49:48 pm by John Hughes »
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #8 on: October 04, 2011, 07:52:47 am »
Bob,

I took a fairly quick look at the driver (not a full driver or code review yet) and things look good. I did come up with the following mostly minor changes:


All that after a quick look?  I'm not sure I want you to do a full review :)   Thanks for the feedback.  I'll start making the changes today.

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #9 on: October 05, 2011, 03:08:30 pm »
I've made all the changes suggested by John and uploaded a new version.  Version 1.0.1 is now on my web site.  http://www.bobsplace.com/ElveWUnderground/


iolaus

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Weather Underground Driver
« Reply #10 on: October 05, 2011, 05:05:38 pm »
All that after a quick look?  I'm not sure I want you to do a full review :)   Thanks for the feedback.  I'll start making the changes today.

Ha, don't feel bad Bob.  I'm a .NET consultant and John found plenty of warts in my driver as well. :)

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: Weather Underground Driver
« Reply #11 on: October 06, 2011, 01:13:06 pm »
Bob,

Heh, when I do a full review I will basically just go through the driver submission bullet points at the end of the Device Driver Development document, so I would recommend reviewing them first.

What happens if ReadWeatherData or WeatherForecast fail to retrieve the data due to network or web service issues? You may need to take a closer look at error handling for that.

How does the driver handle icon ids? I see the IconID method you mentioned translates the id... does it return a standard weather channel id or other?
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #12 on: October 07, 2011, 07:09:21 pm »
Bob,

Heh, when I do a full review I will basically just go through the driver submission bullet points at the end of the Device Driver Development document, so I would recommend reviewing them first.
I did look them over before, and spent the time to go through them 1 by 1.  I believe I have everything correct per the list now.

Quote
What happens if ReadWeatherData or WeatherForecast fail to retrieve the data due to network or web service issues? You may need to take a closer look at error handling for that.
Good catch!  This is why I like having someone else review my code. 

Quote
How does the driver handle icon ids? I see the IconID method you mentioned translates the id... does it return a standard weather channel id or other?
Yes, it maps the Weather Underground icon names to standard weather channel ID's as best I can. It's not a one-to-one mapping but I think it's close enough to allow other weather icon sets to be used.  The weather underground provides 8 different icon sets and you can access those through the driver to get ones that map exactly.  Personally, I think the WU sets are too small and they don't scale very well.

I put the new version on my web site at http://www/bobsplace.com/ElveWUnderground/ 

John, the updated source is also available in the same location as before. 

sonata31

  • Sr. Member
  • ****
  • Posts: 307
    • View Profile
    • Dialou Home-Cinéma
Re: Weather Underground Driver
« Reply #13 on: November 23, 2011, 05:31:54 am »
Elve 1.1.0.76

Elve Management Studio > Devices > Weather Underground


bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Weather Underground Driver
« Reply #14 on: November 23, 2011, 02:15:07 pm »

That error probably means that the station you selected is not reporting data, or at least is not reporting a value for location.

This can happen if you select an airport ID for the station ID.  When an airport ID is used, the format of the location data is different.

A new version of the driver has been submitted so the next Elve beta should work better.

Bob

Elve 1.1.0.76

Elve Management Studio > Devices > Weather Underground