[userModule] Wunderground Weather Services

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Post Reply
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

[userModule] Wunderground Weather Services

Post by pz1 » 15 Feb 2015 22:10

Last updated: 2016-11-17
version: 1.1.2
Tested with: v2.2.3-rc1
STATUS: Stable
Download: Online Appstore
Github: Sources, Documentation & License
Wunderground.PNG
Wunderground.PNG (6.46 KiB) Viewed 2001 times
The latest release has three virtual devices; local weather, wind direction, and a Day/Night flag
temperature.PNG
temperature.PNG (4.45 KiB) Viewed 1995 times
winddir.PNG
winddir.PNG (5.91 KiB) Viewed 1995 times
isNight.PNG
isNight.PNG (4.94 KiB) Viewed 1832 times
Rationale
This module is directly derived from the OpenWeather module that comes with the standard Z-Way distribution. The intended use is for those, who feel comfortable to edit little things in some javascript to specify parameters needed for their installations. To use this module you first have to register with Wunderground. See their getting started section, and read it carefully.

Within OpenRemote, I have been using Wunderground for many years, where it has proven to be a stable resource.

With this module, I left the core OpenWeather structure mostly intact, there were only changes in the code that connects via the weather services API. As Wunderground gives temperatures both in Centigrade and Fahrenheit, I removed that choice from the installation screen. Finally I set the timer to update the weather data every 15 minutes (900*1000). At this rate you stay within the boundaries of the free license

In the example below I have specified 5 parameters. The corresponding Wunderground JSON leaf tags are marked in red. Unchanged code is in black

Module method code section to be adapted

try {
var temp = res.data.current_observation.temp_c,
windgust = res.data.current_observation.wind_gust_kph,
observe_time = res.data.current_observation.local_time_rfc822,
max_temp = res.data.forecast.simpleforecast.forecastday[0].high.celsius,
icon = res.data.current_observation.icon_url;

self.vDev.set("metrics:level", temp);
self.vDev.set("metrics:windgust", windgust);
self.vDev.set("metrics:observe_time", observe_time);
self.vDev.set("metrics:max_temp", max_temp);
self.vDev.set("metrics:icon", icon);

} catch (e) {
Wunderground available JSON-tags (Schiphol Airport)

Code: Select all

{
  "response": {
  "version":"0.1",
  "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  "conditions": 1
  ,
  "forecast": 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":"Schiphol, Netherlands",
		"city":"Schiphol",
		"state":"",
		"state_name":"Netherlands",
		"country":"NL",
		"country_iso3166":"NL",
		"zip":"00000",
		"magic":"3",
		"wmo":"06240",
		"latitude":"52.30805588",
		"longitude":"4.76416683",
		"elevation":"-3.00000000"
		},
		"observation_location": {
		"full":"Schiphol, Badhoevedorp, NOORD HOLLAND",
		"city":"Schiphol, Badhoevedorp",
		"state":"NOORD HOLLAND",
		"country":"NETHERLANDS",
		"country_iso3166":"NL",
		"latitude":"52.332226",
		"longitude":"4.781252",
		"elevation":"-10 ft"
		},
		"estimated": {
		},
		"station_id":"INOORDHO84",
		"observation_time":"Last Updated on February 15, 7:42 PM CET",
		"observation_time_rfc822":"Sun, 15 Feb 2015 19:42:32 +0100",
		"observation_epoch":"1424025752",
		"local_time_rfc822":"Sun, 15 Feb 2015 19:49:05 +0100",
		"local_epoch":"1424026145",
		"local_tz_short":"CET",
		"local_tz_long":"Europe/Amsterdam",
		"local_tz_offset":"+0100",
		"weather":"Partly Cloudy",
		"temperature_string":"36.3 F (2.4 C)",
		"temp_f":36.3,
		"temp_c":2.4,
		"relative_humidity":"87%",
		"wind_string":"From the ENE at 2.0 MPH Gusting to 6.0 MPH",
		"wind_dir":"ENE",
		"wind_degrees":62,
		"wind_mph":2.0,
		"wind_gust_mph":"6.0",
		"wind_kph":3.2,
		"wind_gust_kph":"9.7",
		"pressure_mb":"1016",
		"pressure_in":"30.01",
		"pressure_trend":"0",
		"dewpoint_string":"33 F (1 C)",
		"dewpoint_f":33,
		"dewpoint_c":1,
		"heat_index_string":"NA",
		"heat_index_f":"NA",
		"heat_index_c":"NA",
		"windchill_string":"36 F (2 C)",
		"windchill_f":"36",
		"windchill_c":"2",
		"feelslike_string":"36 F (2 C)",
		"feelslike_f":"36",
		"feelslike_c":"2",
		"visibility_mi":"2.8",
		"visibility_km":"4.5",
		"solarradiation":"0",
		"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":"partlycloudy",
		"icon_url":"http://icons.wxug.com/i/c/k/nt_partlycloudy.gif",
		"forecast_url":"http://www.wunderground.com/global/stations/06240.html",
		"history_url":"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=INOORDHO84",
		"ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=52.332226,4.781252",
		"nowcast":""
	}
		,
	"forecast":{
		"txt_forecast": {
		"date":"6:58 PM CET",
		"forecastday": [
		{
		"period":0,
		"icon":"clear",
		"icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
		"title":"Sunday",
		"fcttext":"Clear. Lows overnight in the upper 20s.",
		"fcttext_metric":"Clear. Low -2C.",
		"pop":"0"
		}
		,
		{
		"period":1,
		"icon":"nt_clear",
		"icon_url":"http://icons.wxug.com/i/c/k/nt_clear.gif",
		"title":"Sunday Night",
		"fcttext":"Clear skies. Low 28F. Winds ESE at 5 to 10 mph.",
		"fcttext_metric":"Clear skies. Low -2C. Winds ESE at 10 to 15 km/h.",
		"pop":"0"
		}
		,
		{
		"period":2,
		"icon":"clear",
		"icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
		"title":"Monday",
		"fcttext":"Sunny. High 48F. Winds S at 5 to 10 mph.",
		"fcttext_metric":"A mainly sunny sky. High 9C. Winds S at 10 to 15 km/h.",
		"pop":"0"
		}
		,
		{
		"period":3,
		"icon":"nt_partlycloudy",
		"icon_url":"http://icons.wxug.com/i/c/k/nt_partlycloudy.gif",
		"title":"Monday Night",
		"fcttext":"Partly cloudy early with increasing clouds overnight. Low 36F. Winds SSW at 5 to 10 mph.",
		"fcttext_metric":"Partly cloudy early with increasing clouds overnight. Low 2C. Winds light and variable.",
		"pop":"20"
		}
		,
		{
		"period":4,
		"icon":"partlycloudy",
		"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
		"title":"Tuesday",
		"fcttext":"Cloudy skies early, followed by partial clearing. High 48F. Winds NNW at 10 to 20 mph.",
		"fcttext_metric":"Cloudy early with partial sunshine expected late. High 9C. Winds NNW at 15 to 30 km/h.",
		"pop":"10"
		}
		,
		{
		"period":5,
		"icon":"nt_clear",
		"icon_url":"http://icons.wxug.com/i/c/k/nt_clear.gif",
		"title":"Tuesday Night",
		"fcttext":"Generally fair. Low 33F. Winds WSW at 5 to 10 mph.",
		"fcttext_metric":"Mainly clear skies. Low near 0C. Winds WSW at 10 to 15 km/h.",
		"pop":"10"
		}
		,
		{
		"period":6,
		"icon":"partlycloudy",
		"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
		"title":"Wednesday",
		"fcttext":"Partly cloudy skies. High 47F. Winds SW at 10 to 15 mph.",
		"fcttext_metric":"Partly cloudy skies. High 8C. Winds SW at 15 to 25 km/h.",
		"pop":"10"
		}
		,
		{
		"period":7,
		"icon":"nt_clear",
		"icon_url":"http://icons.wxug.com/i/c/k/nt_clear.gif",
		"title":"Wednesday Night",
		"fcttext":"A mostly clear sky. Low 33F. Winds SSW at 10 to 15 mph.",
		"fcttext_metric":"Clear. Low 1C. Winds SSW at 10 to 15 km/h.",
		"pop":"10"
		}
		]
		},
		"simpleforecast": {
		"forecastday": [
		{"date":{
	"epoch":"1424023200",
	"pretty":"7:00 PM CET on February 15, 2015",
	"day":15,
	"month":2,
	"year":2015,
	"yday":45,
	"hour":19,
	"min":"00",
	"sec":0,
	"isdst":"0",
	"monthname":"February",
	"monthname_short":"Feb",
	"weekday_short":"Sun",
	"weekday":"Sunday",
	"ampm":"PM",
	"tz_short":"CET",
	"tz_long":"Europe/Amsterdam"
},
		"period":1,
		"high": {
		"fahrenheit":"45",
		"celsius":"7"
		},
		"low": {
		"fahrenheit":"28",
		"celsius":"-2"
		},
		"conditions":"Clear",
		"icon":"clear",
		"icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
		"skyicon":"",
		"pop":0,
		"qpf_allday": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_day": {
		"in": null,
		"mm": null
		},
		"qpf_night": {
		"in": 0.00,
		"mm": 0
		},
		"snow_allday": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_day": {
		"in": null,
		"cm": null
		},
		"snow_night": {
		"in": 0.0,
		"cm": 0.0
		},
		"maxwind": {
		"mph": 15,
		"kph": 24,
		"dir": "",
		"degrees": 0
		},
		"avewind": {
		"mph": 4,
		"kph": 6,
		"dir": "ENE",
		"degrees": 60
		},
		"avehumidity": 93,
		"maxhumidity": 0,
		"minhumidity": 0
		}
		,
		{"date":{
	"epoch":"1424109600",
	"pretty":"7:00 PM CET on February 16, 2015",
	"day":16,
	"month":2,
	"year":2015,
	"yday":46,
	"hour":19,
	"min":"00",
	"sec":0,
	"isdst":"0",
	"monthname":"February",
	"monthname_short":"Feb",
	"weekday_short":"Mon",
	"weekday":"Monday",
	"ampm":"PM",
	"tz_short":"CET",
	"tz_long":"Europe/Amsterdam"
},
		"period":2,
		"high": {
		"fahrenheit":"48",
		"celsius":"9"
		},
		"low": {
		"fahrenheit":"36",
		"celsius":"2"
		},
		"conditions":"Clear",
		"icon":"clear",
		"icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
		"skyicon":"",
		"pop":0,
		"qpf_allday": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_day": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_night": {
		"in": 0.00,
		"mm": 0
		},
		"snow_allday": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_day": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_night": {
		"in": 0.0,
		"cm": 0.0
		},
		"maxwind": {
		"mph": 10,
		"kph": 16,
		"dir": "S",
		"degrees": 170
		},
		"avewind": {
		"mph": 8,
		"kph": 13,
		"dir": "S",
		"degrees": 170
		},
		"avehumidity": 79,
		"maxhumidity": 0,
		"minhumidity": 0
		}
		,
		{"date":{
	"epoch":"1424196000",
	"pretty":"7:00 PM CET on February 17, 2015",
	"day":17,
	"month":2,
	"year":2015,
	"yday":47,
	"hour":19,
	"min":"00",
	"sec":0,
	"isdst":"0",
	"monthname":"February",
	"monthname_short":"Feb",
	"weekday_short":"Tue",
	"weekday":"Tuesday",
	"ampm":"PM",
	"tz_short":"CET",
	"tz_long":"Europe/Amsterdam"
},
		"period":3,
		"high": {
		"fahrenheit":"48",
		"celsius":"9"
		},
		"low": {
		"fahrenheit":"33",
		"celsius":"1"
		},
		"conditions":"Partly Cloudy",
		"icon":"partlycloudy",
		"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
		"skyicon":"",
		"pop":10,
		"qpf_allday": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_day": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_night": {
		"in": 0.00,
		"mm": 0
		},
		"snow_allday": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_day": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_night": {
		"in": 0.0,
		"cm": 0.0
		},
		"maxwind": {
		"mph": 20,
		"kph": 32,
		"dir": "NNW",
		"degrees": 335
		},
		"avewind": {
		"mph": 13,
		"kph": 21,
		"dir": "NNW",
		"degrees": 335
		},
		"avehumidity": 80,
		"maxhumidity": 0,
		"minhumidity": 0
		}
		,
		{"date":{
	"epoch":"1424282400",
	"pretty":"7:00 PM CET on February 18, 2015",
	"day":18,
	"month":2,
	"year":2015,
	"yday":48,
	"hour":19,
	"min":"00",
	"sec":0,
	"isdst":"0",
	"monthname":"February",
	"monthname_short":"Feb",
	"weekday_short":"Wed",
	"weekday":"Wednesday",
	"ampm":"PM",
	"tz_short":"CET",
	"tz_long":"Europe/Amsterdam"
},
		"period":4,
		"high": {
		"fahrenheit":"47",
		"celsius":"8"
		},
		"low": {
		"fahrenheit":"33",
		"celsius":"1"
		},
		"conditions":"Partly Cloudy",
		"icon":"partlycloudy",
		"icon_url":"http://icons.wxug.com/i/c/k/partlycloudy.gif",
		"skyicon":"",
		"pop":10,
		"qpf_allday": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_day": {
		"in": 0.00,
		"mm": 0
		},
		"qpf_night": {
		"in": 0.00,
		"mm": 0
		},
		"snow_allday": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_day": {
		"in": 0.0,
		"cm": 0.0
		},
		"snow_night": {
		"in": 0.0,
		"cm": 0.0
		},
		"maxwind": {
		"mph": 15,
		"kph": 24,
		"dir": "SW",
		"degrees": 218
		},
		"avewind": {
		"mph": 12,
		"kph": 19,
		"dir": "SW",
		"degrees": 218
		},
		"avehumidity": 78,
		"maxhumidity": 0,
		"minhumidity": 0
		}
		]
		}
	}
}

Usage for remote calls (e.g. with OpenRemote)
After Selecting the the Wunderground in the HA interface, a virtual device Wunderground_XX is created. XX depends on your installation. To see the available parameters do either:

Code: Select all

http://raspberry_IP:8083/JS/Run/controller.devices.get("Wunderground_72").get("metrics")
or
http://raspberry_IP:8083/OpenRemote/metrics/Wunderground_72/
This results in the following JSON

Code: Select all

	
{
	"scaleTitle" : "°C",
	"title" : "Schiphol",
	"probeTitle" : "Temperature",
	"level" : "2.4",
	"windgust" : "9.7",
	"observe_time" : "Sun, 15 Feb 2015 16:20:44 +0100",
	"icon" : "http://icons.wxug.com/i/c/k/mostlycloudy.gif"
}
To get the parameter value do either:

Code: Select all

http://raspberry_IP:8083/JS/Run/controller.devices.get("Wunderground_72").get("metrics:windgust")
or
http://raspberry_IP:8083/OpenRemote/metrics/Wunderground_72/windgust
Known Issues
  • Some city names do not appear to work for retrieving data. Specify a nearby place.
Since 29-12-2016 I am no longer a moderator for this forum

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] Wunderground Weather Services

Post by pz1 » 17 Nov 2016 14:36

This simple Wunderground App has been updated. It's is designed to operate via the OpenRemoteHelpers App, but is not limited to use with OpenRemote.
Latest features are a cardinal wind direction sensor, and a coarse day/night indicator. It is available via the App store now. First post here is updated accordingly

Those who want a more extensive weather report should seriously consider Maros Kollar's excellent Weather App

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 4 guests