Weather Underground Web Smartapp: the "poor guy" weather station with event based switches automation [Deprecated. See Weather Company version below]

[ Deprecated see [Release] The Weather Company SmartApp: the “poor guy” weather station with event based switches automation for Weather Company version]

Hi there,

I was looking for a smartapp to automate things depending on weather conditions without having another device to buy.

[UPDATED]: Thanks to @Dianoga (see below posts), I simply use ST API to access WeatherUnderground data. No need anymore for your own WU API key.

Settings are expressed in the unit (F or C) you set-up for your location.

The rain, snow and storm are triggered upon real events but also “chance of” event (see Weather Underground definitions).

Setup: install the smartapp and devicehandler in your IDE and publish it for yourself

(Owner: philippeportesppo Name: WeatherUndergroundWeb_SmartThings Branch: develop)

Alert settings: set-up the parameters for your alerts like temperature min/max, humidity min/max and rain, storm and snow alerts.

Action settings: set-up “Switch on/off” per event to indicate which switch(es) you want to turn on or off upon an event occurrence.

After the SmartApp parameter saving, the device handler is created under a composed name with the “Weather in city,state”.

This device details allows to see the values provided by Weather Underground:
-Temperature
-Real feel
-Dew point
-Relative Humidity
-Weather condition (icon and description)

I will let this development on my GitHub “develop” branch for 2 weeks before merging it to the master so that I can collect feedbacks/issues from the community, so feel free to comment and share.

Hope you like it

5 Likes

Weather Underground issues a 3 digit code for weather conditions. Is there a way to extract that code from your DTH? I looked it over and it’s probably there, I just couldn’t figure it out.

I can check that. I use 2 infornation: icon_url that displays the icons matching the weather string displayed in the bottom tile.

In the past I was deducting the weather string but I realized last summer that a Haze icon was used with a different label during Californian wildfires. So I had to revert to icon_url+label from WU.

Here are the fields provided by the free API. In my DTH, they are accessed as JSON (example: resp.data.current_observation.feelslike_c)

{
“response”: {
“version”:“0.1”,
“termsofService”:“http://www.wunderground.com/weather/api/d/terms.html”,
“features”: {
“conditions”: 1
}
}
, “current_observation”: {
“image”: {
“url”:“http://icons.wxug.com/graphics/wu2/logo_130x80.png”,
“title”:“Weather Underground”,
“link”:“http://www.wunderground.com
},
“display_location”: {
“full”:“Boston, NY”,
“city”:“Boston”,
“state”:“NY”,
“state_name”:“New York”,
“country”:“US”,
“country_iso3166”:“US”,
“zip”:“14025”,
“magic”:“1”,
“wmo”:“99999”,
“latitude”:“42.63000107”,
“longitude”:"-78.73999786",
“elevation”:“286.8”
},
“observation_location”: {
“full”:“East Hill, Colden, New York”,
“city”:“East Hill, Colden”,
“state”:“New York”,
“country”:“US”,
“country_iso3166”:“US”,
“latitude”:“42.654877”,
“longitude”:"-78.702362",
“elevation”:“1594 ft”
},
“estimated”: {
},
“station_id”:“KNYCOLDE2”,
“observation_time”:“Last Updated on February 22, 10:39 AM EST”,
“observation_time_rfc822”:“Thu, 22 Feb 2018 10:39:56 -0500”,
“observation_epoch”:“1519313996”,
“local_time_rfc822”:“Thu, 22 Feb 2018 10:41:18 -0500”,
“local_epoch”:“1519314078”,
“local_tz_short”:“EST”,
“local_tz_long”:“America/New_York”,
“local_tz_offset”:"-0500",
“weather”:“Snow”,
“temperature_string”:“29.8 F (-1.2 C)”,
“temp_f”:29.8,
“temp_c”:-1.2,
“relative_humidity”:“94%”,
“wind_string”:“From the East at 3.0 MPH Gusting to 6.0 MPH”,
“wind_dir”:“East”,
“wind_degrees”:90,
“wind_mph”:3.0,
“wind_gust_mph”:“6.0”,
“wind_kph”:4.8,
“wind_gust_kph”:“9.7”,
“pressure_mb”:“1038”,
“pressure_in”:“30.64”,
“pressure_trend”:"+",
“dewpoint_string”:“28 F (-2 C)”,
“dewpoint_f”:28,
“dewpoint_c”:-2,
“heat_index_string”:“NA”,
“heat_index_f”:“NA”,
“heat_index_c”:“NA”,
“windchill_string”:“30 F (-1 C)”,
“windchill_f”:“30”,
“windchill_c”:"-1",
“feelslike_string”:“30 F (-1 C)”,
“feelslike_f”:“30”,
feelslike_c”:"-1",
“visibility_mi”:“10.0”,
“visibility_km”:“16.1”,
“solarradiation”:“65”,
“UV”:“0.0”,“precip_1hr_string”:“0.00 in ( 0 mm)”,
“precip_1hr_in”:“0.00”,
“precip_1hr_metric”:" 0",
“precip_today_string”:“0.00 in (0 mm)”,
“precip_today_in”:“0.00”,
“precip_today_metric”:“0”,
“icon”:“snow”,
“icon_url”:“http://icons.wxug.com/i/c/k/snow.gif”,
“forecast_url”:“http://www.wunderground.com/US/NY/Boston.html”,
“history_url”:“http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KNYCOLDE2”,
“ob_url”:“http://www.wunderground.com/cgi-bin/findweather/getForecast?query=42.654877,-78.702362”,
“nowcast”:""
}
}

1 Like

If you do the URL for alerts in place of conditions you get what I was looking for. I did some testing and modified my own smartapp to get what I wanted. By looking at your code I was able to figure out how to do it. Thanks for doing all the hard work…:slight_smile:

What I am doing is looking at a few select alert types and sending me an alert if one of them occurs.

I see what you mean now.

I’ll add that later based on https://www.wunderground.com/weather/api/d/docs?d=data/alerts

Thanks for hint, I never checked that API

I haven’t actually seen any alerts yet, but I believe it should work. I am using the cumulus plan. The docs say you can get multiple items with one call. Such as both conditions and alertd, for example.

I tried getting a key, but it requires a web site to be filled in. How do you get a key without that filled in?

I think I gave my github repository url. not sure. I did that last year. You can put your linkedin or whatever you have as a personal page.

I had that same issue. I put in www.smartthings.com and it worked. Not sure what they would use it for.

One thing I’m puzzled on in the alerts. It appears that if there is no alert the field values are []. I see that by using a log.debug. But if I do if (item != “[]”) it doesn’t seem to work. The if statement executes anyway. So I’m kinda waiting for an alert to see what the actual value looks like.

Just to confirm, are you talking about your code or mine?
To test my code I just set the settings to a city that has currently the weather condition I want to check the alert against or i put very irrelevant threshold values so that I don’t need the event to be triggered in my area.

If you don’t want to use your own API key, you can use ours. Check out getWeatherFeature in the docs.

1 Like

[] is an array. I think you can just check for truthyness on the item if (item)

Sometimes the brain doesn’t kick in with out a bump or 2. I should have realized that was an array…:slight_smile:

Trying to install, but I think IDE is still down, can anyone confirm this?

Am trying the getWeatherFeature. I get a response ok. What I can’t figure out is how to parse the response. Here is what I am doing.

def params = getWeatherFeature(“alerts”,“zip”)

How do I separate the params out?

EDIT: Never mind, I got it. Not sure I understand, but I got it figured out.

Are you still having troubles? Where are you stuck?
I just connected and seems ok.

Alert example with my implementation would drive to this if something happens:

{
“response”: {
“version”:“0.1”,
“termsofService”:“http://www.wunderground.com/weather/api/d/terms.html”,
“features”: {
“alerts”: 1
}
}
,“query_zone”: “085”,
“alerts”: [
{
“type”: “FOG”,
“description”: “Dense Fog Advisory, High Wind Watch”,
“date”: “9:34 PM EST on February 23, 2018”,
“date_epoch”: “1519439640”,
“expires”: “6:00 PM EST on February 25, 2018”,
“expires_epoch”: “1519599600”,
“tz_short”:“EST”,
“tz_long”:“America/New_York”,
“message”: “\u000A…Dense fog advisory in effect until 6 am EST Saturday…\u000A…High wind watch remains in effect from Sunday morning through\u000ASunday afternoon…\u000A\u000AThe National Weather Service in Buffalo has issued a dense fog\u000Aadvisory, which is in effect until 6 am EST Saturday.\u000A\u000A* Locations…Wyoming and southern Erie counties.\u000A\u000A* Timing…the dense fog advisory is in effect through late\u000A tonight…mainly for elevations above 1000 feet. The high wind \u000A watch is in effect from late Sunday morning through early Sunday\u000A evening.\u000A\u000A* Winds…southwest 25 to 35 mph with gusts up to 50 mph on Sunday.\u000A\u000A* Visibilities…near zero at times across the higher terrain.\u000A\u000A* Impacts…poor travel conditions across the higher terrain\u000A overnight. Strong to damaging winds possible on Sunday. Shallow\u000A rooted trees may be downed more easily with the recently thawed\u000A and saturated soil conditions. Travel may become hazardous for \u000A high profile vehicles.\u000A\u000APrecautionary/preparedness actions…\u000A\u000AStrong winds of 58 mph or greater could produce property damage,\u000Aincluding downed trees and power lines that could result in power\u000Aoutages. Home owners should secure personal property.\u000A\u000AA dense fog advisory is issued when dense fog will substantially\u000Areduce visibilities, resulting in hazardous driving conditions in\u000Asome areas. Motorists are advised to use caution and slow down,\u000Aas objects on and near roadways will be seen only at close range.\u000AStay tuned to weather radio or other radio and TV stations for\u000Afurther details or updates.\u000A\u000A\u000A\u000A\u000A\u000A\u000A”,
“phenomena”: “HW”,
“significance”: “A”,
“ZONES”: [
{
“state”:“NY”,
“ZONE”:“012”
}
,
{
“state”:“NY”,
“ZONE”:“085”
}
],
“StormBased”: {
}
}
]
}

Otherwise, it looks like this:

{
“response”: {
“version”:“0.1”,
“termsofService”:“http://www.wunderground.com/weather/api/d/terms.html”,
“features”: {
“alerts”: 1
}
}
,“query_zone”: “513”,
“alerts”: [
]
}

You see your [] you had concerns with.

Once you are having something, the access is through the map like:

def mymap = getWeatherFeature(“conditions”,“AZ/Flagstaff”)
log.debug mymap[‘current_observation’][‘relative_humidity’]

Hey great interface I missed.

Can you confirm if there is any limitation like number of calls per minutes per user?
Do you guys have a special deal with WU with unlimited number of users/calls?

Otherwise, it means we could be limited in its usage and miss some events/automations because we would be like 10k people requesting every 5min the weather conditions through our smartapps.

I don’t think we have a limit on it. We pay wunderground, but I don’t know what the terms are. My station updates every minute.

1 Like