Can anyone help?
Posted: Fri Apr 07, 2017 8:03 am
I'm trying to get the info from Wunderground to show on a weather station I'm building
I can get it to work fine using openweathermap.org but I can't get Wunderground to work
Anyone able to help?
This is what works with openweathermap
This is my code for Wunderground but it fails on LINE 22
This is the actual full return from the API call that I'm trying to parse
I'd like to get this working so I can then work on the forecast which again works fine in openweathermap*
Thanks in advance
I can get it to work fine using openweathermap.org but I can't get Wunderground to work
Anyone able to help?
This is what works with openweathermap
Code: Select all
timesetup(1)
print time()
delay 1000
print time()
timer 10 * 1000, [RUNPROGRAM]
wait
[RUNPROGRAM]
cls
PRINT "TIME" & "," & time()
serialprintln "TIME" & "," & time()
let query = "api.openweathermap.org/data/2.5/weather?q=Denton,uk&lang=en&units=metric&appid=API_KEY_HERE"
delay 500
let ret = wget(query)
let temp = json(ret,"main.temp")
let press = json(ret,"main.pressure")
let humid = json(ret,"main.humidity")
let speed = json(ret,"main.speed")
speed1 = int(main.speed + 0.5)
let dir = json(ret,"main.deg")
let icon = json(ret,"main.icon")
let desc = json(ret,"description")
println "Today," & desc & "," & icon & "," & temp & "," & press &"," & speed1 & "," & dir & "," & humid
This is my code for Wunderground but it fails on LINE 22
Code: Select all
timesetup(1)
print time()
delay 1000
print time()
timer 10 * 1000, [RUNPROGRAM]
wait
[RUNPROGRAM]
cls
PRINT "TIME" & "," & time()
'println "TIME" & "," & time()
let query = "api.wunderground.com/api/API_KEY_HERE/conditions/q/UK/Audenshaw.json"
delay 10
let ret = wget(query)
let temp = json(ret,"temp_c")
let press = json(ret,"pressure_mb")
let humid = json(ret,"relative_humidity")
let speed = json(ret,"main.speed")
speed1 = int(wind_mph)
let dir = json(ret,"wind_degrees")
let icon = json(ret,"icon")
let desc = json(ret,"wind_string")
println "Today," & desc & "," & icon & "," & temp & "," & press &"," & speed1 & "," & dir & "," & humid
This is the actual full return from the API call that I'm trying to parse
{
"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":"Audenshaw, United Kingdom",
"city":"Audenshaw",
"state":"TAM",
"state_name":"United Kingdom",
"country":"UK",
"country_iso3166":"GB",
"zip":"00000",
"magic":"71",
"wmo":"03334",
"latitude":"53.45000076",
"longitude":"-2.11999989",
"elevation":"79.9"
},
"observation_location": {
"full":"Denton, Denton, ",
"city":"Denton, Denton",
"state":"",
"country":"GB",
"country_iso3166":"GB",
"latitude":"53.441669",
"longitude":"-2.149535",
"elevation":"256 ft"
},
"estimated": {
},
"station_id":"IDENTON2",
"observation_time":"Last Updated on April 7, 4:51 PM BST",
"observation_time_rfc822":"Fri, 07 Apr 2017 16:51:29 +0100",
"observation_epoch":"1491580289",
"local_time_rfc822":"Fri, 07 Apr 2017 16:52:09 +0100",
"local_epoch":"1491580329",
"local_tz_short":"BST",
"local_tz_long":"Europe/London",
"local_tz_offset":"+0100",
"weather":"Clear",
"temperature_string":"61.3 F (16.3 C)",
"temp_f":61.3,
"temp_c":16.3,
"relative_humidity":"46%",
"wind_string":"From the SSW at 7.2 MPH Gusting to 14.3 MPH",
"wind_dir":"SSW",
"wind_degrees":202,
"wind_mph":7.2,
"wind_gust_mph":"14.3",
"wind_kph":11.6,
"wind_gust_kph":"23.0",
"pressure_mb":"1026",
"pressure_in":"30.30",
"pressure_trend":"0",
"dewpoint_string":"40 F (5 C)",
"dewpoint_f":40,
"dewpoint_c":5,
"heat_index_string":"NA",
"heat_index_f":"NA",
"heat_index_c":"NA",
"windchill_string":"NA",
"windchill_f":"NA",
"windchill_c":"NA",
"feelslike_string":"61.3 F (16.3 C)",
"feelslike_f":"61.3",
"feelslike_c":"16.3",
"visibility_mi":"6.2",
"visibility_km":"10.0",
"solarradiation":"--",
"UV":"3","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":"clear",
"icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
"forecast_url":"http://www.wunderground.com/global/stations/03334.html",
"history_url":"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IDENTON2",
"ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=53.441669,-2.149535",
"nowcast":""
}
}
I'd like to get this working so I can then work on the forecast which again works fine in openweathermap*
Thanks in advance