I didn’t like the OpenWeatherMap forecast, it wasn’t very accurate for my location. I’ve been getting weather from the NWS for years and it has always been the most accurate… I’m not a big talker so here’s what I’ve got… I was pretty happy with the widget that was provided for OpenWeatherMap, so I ended up reusing most of the code from that widget. I hope that doesn’t upset anyone…
For the HTTP_URL_Thing_Weather item, we pass the API URL for our area:
https://api.weather.gov/gridpoints/{Station Name}/{gridpoints,gridpoints}/forecast
To get the Station Name and grid point values, you must follow the instructions provided at api.weather.gov: General FAQs
For example, you can paste https://api.weather.gov/points/{lat},{lon}
into your browser and put your latitude/longitude in, and the API will return back the appropriate link for your HTTP URL Thing under “Properties > Forecast”
I set up a refresh time of 6000 with a timeout of 15000. YMMV, adjust as needed…
HTTP_URL_Thing_Weather : This item is an HTTP URL thing (using the HTTP binding) It holds the JSON data that we get from the NWS API
df0 through df13 : These items hold the detailed forecast
weather0day through weather13day : These items hold a boolean value whether this is during the day or at night
weather0forecast : This item holds the timestamp for when the forecast was generated
weather0icon through weather13icon : These items hold the address for where the icon for the corresponding forecast can be loaded
weather0name through weather13name : These items hold the name of the forecast period (i.e.: Today, Tonight, Sunday, Sunday Night, etc)
weather0rh : This item holds the value of the relative humidity for the current period
weather0sf through weather13sf : These items hold the value of a brief summary of the forecast for that period
weather0temp through weather13temp : These items hold the value of the forecast temperature for that period
weather0tempu through weather13tempu : These items hold the value of the temperature unit used for that period
weather0wind : This item holds the value of the wind speed (including units) of the current period
rule weather
when
Item HTTP_URL_Thing_Weather received update
then
val String json = (HTTP_URL_Thing_Weather.state as StringType).toString
val String icon0 = transform("JSONPATH", "$.properties.periods[0].icon", json)
val String icon1 = transform("JSONPATH", "$.properties.periods[1].icon", json)
val String icon2 = transform("JSONPATH", "$.properties.periods[2].icon", json)
val String icon3 = transform("JSONPATH", "$.properties.periods[3].icon", json)
val String icon4 = transform("JSONPATH", "$.properties.periods[4].icon", json)
val String icon5 = transform("JSONPATH", "$.properties.periods[5].icon", json)
val String icon6 = transform("JSONPATH", "$.properties.periods[6].icon", json)
val String icon7 = transform("JSONPATH", "$.properties.periods[7].icon", json)
val String icon8 = transform("JSONPATH", "$.properties.periods[8].icon", json)
val String icon9 = transform("JSONPATH", "$.properties.periods[9].icon", json)
val String icon10 = transform("JSONPATH", "$.properties.periods[10].icon", json)
val String icon11 = transform("JSONPATH", "$.properties.periods[11].icon", json)
val String icon12 = transform("JSONPATH", "$.properties.periods[12].icon", json)
val String icon13 = transform("JSONPATH", "$.properties.periods[13].icon", json)
val String name0 = transform("JSONPATH", "$.properties.periods[0].name", json)
val String name1 = transform("JSONPATH", "$.properties.periods[1].name", json)
val String name2 = transform("JSONPATH", "$.properties.periods[2].name", json)
val String name3 = transform("JSONPATH", "$.properties.periods[3].name", json)
val String name4 = transform("JSONPATH", "$.properties.periods[4].name", json)
val String name5 = transform("JSONPATH", "$.properties.periods[5].name", json)
val String name6 = transform("JSONPATH", "$.properties.periods[6].name", json)
val String name7 = transform("JSONPATH", "$.properties.periods[7].name", json)
val String name8 = transform("JSONPATH", "$.properties.periods[8].name", json)
val String name9 = transform("JSONPATH", "$.properties.periods[9].name", json)
val String name10 = transform("JSONPATH", "$.properties.periods[10].name", json)
val String name11 = transform("JSONPATH", "$.properties.periods[11].name", json)
val String name12 = transform("JSONPATH", "$.properties.periods[12].name", json)
val String name13 = transform("JSONPATH", "$.properties.periods[13].name", json)
val String sf0 = transform("JSONPATH", "$.properties.periods[0].shortForecast", json)
val String sf1 = transform("JSONPATH", "$.properties.periods[1].shortForecast", json)
val String sf2 = transform("JSONPATH", "$.properties.periods[2].shortForecast", json)
val String sf3 = transform("JSONPATH", "$.properties.periods[3].shortForecast", json)
val String sf4 = transform("JSONPATH", "$.properties.periods[4].shortForecast", json)
val String sf5 = transform("JSONPATH", "$.properties.periods[5].shortForecast", json)
val String sf6 = transform("JSONPATH", "$.properties.periods[6].shortForecast", json)
val String sf7 = transform("JSONPATH", "$.properties.periods[7].shortForecast", json)
val String sf8 = transform("JSONPATH", "$.properties.periods[8].shortForecast", json)
val String sf9 = transform("JSONPATH", "$.properties.periods[9].shortForecast", json)
val String sf10 = transform("JSONPATH", "$.properties.periods[10].shortForecast", json)
val String sf11 = transform("JSONPATH", "$.properties.periods[11].shortForecast", json)
val String sf12 = transform("JSONPATH", "$.properties.periods[12].shortForecast", json)
val String sf13 = transform("JSONPATH", "$.properties.periods[13].shortForecast", json)
val String temp0 = transform("JSONPATH", "$.properties.periods[0].temperature", json)
val String temp1 = transform("JSONPATH", "$.properties.periods[1].temperature", json)
val String temp2 = transform("JSONPATH", "$.properties.periods[2].temperature", json)
val String temp3 = transform("JSONPATH", "$.properties.periods[3].temperature", json)
val String temp4 = transform("JSONPATH", "$.properties.periods[4].temperature", json)
val String temp5 = transform("JSONPATH", "$.properties.periods[5].temperature", json)
val String temp6 = transform("JSONPATH", "$.properties.periods[6].temperature", json)
val String temp7 = transform("JSONPATH", "$.properties.periods[7].temperature", json)
val String temp8 = transform("JSONPATH", "$.properties.periods[8].temperature", json)
val String temp9 = transform("JSONPATH", "$.properties.periods[9].temperature", json)
val String temp10 = transform("JSONPATH", "$.properties.periods[10].temperature", json)
val String temp11 = transform("JSONPATH", "$.properties.periods[11].temperature", json)
val String temp12 = transform("JSONPATH", "$.properties.periods[12].temperature", json)
val String temp13 = transform("JSONPATH", "$.properties.periods[13].temperature", json)
val String temp0u = transform("JSONPATH", "$.properties.periods[0].temperatureUnit", json)
val String temp1u = transform("JSONPATH", "$.properties.periods[1].temperatureUnit", json)
val String temp2u = transform("JSONPATH", "$.properties.periods[2].temperatureUnit", json)
val String temp3u = transform("JSONPATH", "$.properties.periods[3].temperatureUnit", json)
val String temp4u = transform("JSONPATH", "$.properties.periods[4].temperatureUnit", json)
val String temp5u = transform("JSONPATH", "$.properties.periods[5].temperatureUnit", json)
val String temp6u = transform("JSONPATH", "$.properties.periods[6].temperatureUnit", json)
val String temp7u = transform("JSONPATH", "$.properties.periods[7].temperatureUnit", json)
val String temp8u = transform("JSONPATH", "$.properties.periods[8].temperatureUnit", json)
val String temp9u = transform("JSONPATH", "$.properties.periods[9].temperatureUnit", json)
val String temp10u = transform("JSONPATH", "$.properties.periods[10].temperatureUnit", json)
val String temp11u = transform("JSONPATH", "$.properties.periods[11].temperatureUnit", json)
val String temp12u = transform("JSONPATH", "$.properties.periods[12].temperatureUnit", json)
val String temp13u = transform("JSONPATH", "$.properties.periods[13].temperatureUnit", json)
val String day0 = transform("JSONPATH", "$.properties.periods[0].isDaytime", json)
val String day1 = transform("JSONPATH", "$.properties.periods[1].isDaytime", json)
val String day2 = transform("JSONPATH", "$.properties.periods[2].isDaytime", json)
val String day3 = transform("JSONPATH", "$.properties.periods[3].isDaytime", json)
val String day4 = transform("JSONPATH", "$.properties.periods[4].isDaytime", json)
val String day5 = transform("JSONPATH", "$.properties.periods[5].isDaytime", json)
val String day6 = transform("JSONPATH", "$.properties.periods[6].isDaytime", json)
val String day7 = transform("JSONPATH", "$.properties.periods[7].isDaytime", json)
val String day8 = transform("JSONPATH", "$.properties.periods[8].isDaytime", json)
val String day9 = transform("JSONPATH", "$.properties.periods[9].isDaytime", json)
val String day10 = transform("JSONPATH", "$.properties.periods[10].isDaytime", json)
val String day11 = transform("JSONPATH", "$.properties.periods[11].isDaytime", json)
val String day12 = transform("JSONPATH", "$.properties.periods[12].isDaytime", json)
val String day13 = transform("JSONPATH", "$.properties.periods[13].isDaytime", json)
val String rh = transform("JSONPATH", "$.properties.periods[0].relativeHumidity.value", json)
val String wind = transform("JSONPATH", "$.properties.periods[0].windSpeed", json)
val String forecast = transform("JSONPATH", "$.properties.generatedAt", json)
val String wdf0 = transform("JSONPATH", "$.properties.periods[0].detailedForecast", json)
val String wdf1 = transform("JSONPATH", "$.properties.periods[1].detailedForecast", json)
val String wdf2 = transform("JSONPATH", "$.properties.periods[2].detailedForecast", json)
val String wdf3 = transform("JSONPATH", "$.properties.periods[3].detailedForecast", json)
val String wdf4 = transform("JSONPATH", "$.properties.periods[4].detailedForecast", json)
val String wdf5 = transform("JSONPATH", "$.properties.periods[5].detailedForecast", json)
val String wdf6 = transform("JSONPATH", "$.properties.periods[6].detailedForecast", json)
val String wdf7 = transform("JSONPATH", "$.properties.periods[7].detailedForecast", json)
val String wdf8 = transform("JSONPATH", "$.properties.periods[8].detailedForecast", json)
val String wdf9 = transform("JSONPATH", "$.properties.periods[9].detailedForecast", json)
val String wdf10 = transform("JSONPATH", "$.properties.periods[10].detailedForecast", json)
val String wdf11 = transform("JSONPATH", "$.properties.periods[11].detailedForecast", json)
val String wdf12 = transform("JSONPATH", "$.properties.periods[12].detailedForecast", json)
val String wdf13 = transform("JSONPATH", "$.properties.periods[13].detailedForecast", json)
logger.info("name0: " + name0 );
logger.info("short: " + sf0 );
logger.info("icon0: " + icon0 );
logger.info("name1: " + name1 );
logger.info("short: " + sf1 );
logger.info("icon1: " + icon1 );
logger.info("name2: " + name2 );
logger.info("short: " + sf2 );
logger.info("icon2: " + icon2 );
logger.info("name3: " + name3 );
logger.info("short: " + sf3 );
logger.info("icon3: " + icon3 );
logger.info("name4: " + name4 );
logger.info("short: " + sf4 );
logger.info("icon4: " + icon4 );
logger.info("name5: " + name5 );
logger.info("short: " + sf5 );
logger.info("icon5: " + icon5 );
logger.info("name6: " + name6 );
logger.info("short: " + sf6 );
logger.info("icon6: " + icon6 );
logger.info("name7: " + name7 );
logger.info("short: " + sf7 );
logger.info("icon7: " + icon7 );
logger.info("name8: " + name8 );
logger.info("short: " + sf8 );
logger.info("icon8: " + icon8 );
logger.info("name9: " + name9 );
logger.info("short: " + sf9 );
logger.info("icon9: " + icon9 );
logger.info("name10: " + name10 );
logger.info("short: " + sf10 );
logger.info("icon10: " + icon10 );
logger.info("name11: " + name11 );
logger.info("short: " + sf11 );
logger.info("icon11: " + icon11 );
logger.info("name12: " + name12 );
logger.info("short: " + sf12 );
logger.info("icon12: " + icon12 );
logger.info("name13: " + name13 );
logger.info("short: " + sf13 );
logger.info("icon13: " + icon13 );
weather0icon.postUpdate(icon0);
weather1icon.postUpdate(icon1);
weather2icon.postUpdate(icon2);
weather3icon.postUpdate(icon3);
weather4icon.postUpdate(icon4);
weather5icon.postUpdate(icon5);
weather6icon.postUpdate(icon6);
weather7icon.postUpdate(icon7);
weather8icon.postUpdate(icon8);
weather9icon.postUpdate(icon9);
weather10icon.postUpdate(icon10);
weather11icon.postUpdate(icon11);
weather12icon.postUpdate(icon12);
weather13icon.postUpdate(icon13);
weather0sf.postUpdate(sf0);
weather1sf.postUpdate(sf1);
weather2sf.postUpdate(sf2);
weather3sf.postUpdate(sf3);
weather4sf.postUpdate(sf4);
weather5sf.postUpdate(sf5);
weather6sf.postUpdate(sf6);
weather7sf.postUpdate(sf7);
weather8sf.postUpdate(sf8);
weather9sf.postUpdate(sf9);
weather10sf.postUpdate(sf10);
weather11sf.postUpdate(sf11);
weather12sf.postUpdate(sf12);
weather13sf.postUpdate(sf13);
weather0name.postUpdate(name0);
weather1name.postUpdate(name1);
weather2name.postUpdate(name2);
weather3name.postUpdate(name3);
weather4name.postUpdate(name4);
weather5name.postUpdate(name5);
weather6name.postUpdate(name6);
weather7name.postUpdate(name7);
weather8name.postUpdate(name8);
weather9name.postUpdate(name9);
weather10name.postUpdate(name10);
weather11name.postUpdate(name11);
weather12name.postUpdate(name12);
weather13name.postUpdate(name13);
weather0temp.postUpdate(temp0);
weather1temp.postUpdate(temp1);
weather2temp.postUpdate(temp2);
weather3temp.postUpdate(temp3);
weather4temp.postUpdate(temp4);
weather5temp.postUpdate(temp5);
weather6temp.postUpdate(temp6);
weather7temp.postUpdate(temp7);
weather8temp.postUpdate(temp8);
weather9temp.postUpdate(temp9);
weather10temp.postUpdate(temp10);
weather11temp.postUpdate(temp11);
weather12temp.postUpdate(temp12);
weather13temp.postUpdate(temp13);
weather0tempu.postUpdate(temp0u);
weather1tempu.postUpdate(temp1u);
weather2tempu.postUpdate(temp2u);
weather3tempu.postUpdate(temp3u);
weather4tempu.postUpdate(temp4u);
weather5tempu.postUpdate(temp5u);
weather6tempu.postUpdate(temp6u);
weather7tempu.postUpdate(temp7u);
weather8tempu.postUpdate(temp8u);
weather9tempu.postUpdate(temp9u);
weather10tempu.postUpdate(temp10u);
weather11tempu.postUpdate(temp11u);
weather12tempu.postUpdate(temp12u);
weather13tempu.postUpdate(temp13u);
weather0day.postUpdate(day0);
weather1day.postUpdate(day1);
weather2day.postUpdate(day2);
weather3day.postUpdate(day3);
weather4day.postUpdate(day4);
weather5day.postUpdate(day5);
weather6day.postUpdate(day6);
weather7day.postUpdate(day7);
weather8day.postUpdate(day8);
weather9day.postUpdate(day9);
weather10day.postUpdate(day10);
weather11day.postUpdate(day11);
weather12day.postUpdate(day12);
weather13day.postUpdate(day13);
weather0rh.postUpdate(rh);
weather0wind.postUpdate(wind);
weather0forecast.postUpdate(forecast);
df0.postUpdate(wdf0);
df1.postUpdate(wdf1);
df2.postUpdate(wdf2);
df3.postUpdate(wdf3);
df4.postUpdate(wdf4);
df5.postUpdate(wdf5);
df6.postUpdate(wdf6);
df7.postUpdate(wdf7);
df8.postUpdate(wdf8);
df9.postUpdate(wdf9);
df10.postUpdate(wdf10);
df11.postUpdate(wdf11);
df12.postUpdate(wdf12);
df13.postUpdate(wdf13);
end
I hope this helps someone…