There are two APIs, an old one and a newer one. I can’t remember which on that address links to.
For the curious, here is the code I have so far using the newer API. The problem is that the predicted precipitation comes in an indeterminate number of elements that need to be iterated through and the values extracted and summed to get the estimate for the full day. The data is XML (it’s government so of course it is) so the code to do that is going to be ugly as a Rule.
But if it helps, here is what I have so far (NOTE, this is the forecast endpoint, they have a different current conditions endpoint):
rule "NOAA Weather"
when
System started
then
logInfo(logName, "Started NOAA query")
val BASE_URL = "https://graphical.weather.gov/xml/sample_products/browser_interface/ndfdXMLclient.php?lat={0}&lon={1}&product=time-series&begin={2}&end={3}"
val LOC_URL = BASE_URL.replace("{0}", "XX.XXXXXX").replace("{1}", "XXX.XXXXXX")
val todayStart = now.withTimeAtStartOfDay.withZone(DateTimeZone.UTC).toString("yyyy-MM-dd'T'HH:mm")
val todayEnd = now.withTimeAtStartOfDay.plusDays(1).withZone(DateTimeZone.UTC).toString("yyyy-MM-dd'T'HH:mm")
val TODAY_URL = LOC_URL.replace("{2}", todayStart).replace("{3}", todayEnd)
// val tomorrowStart = todayEnd
// val tomorrowEnd = now.withTimeAtStartOfDay.plusDays(2).toString("yyyy-MM-dd'T'HH:mm")
// val TOMORROW_URL = LOC_URL.replace("{2}", tomorrowStart).replace("{3}", tomorrowEnd)
logInfo(logName, "Checking today with " + TODAY_URL)
val todayForecast = sendHttpGetRequest(TODAY_URL, 20000)
// logInfo(logName, "Checking tomorrow with " + TOMORROW_URL)
// val tomorrowForecast = sendHttpGetRequest(TOMORROW_URL, 20000)
val todayPrecipitation = transform("XSLT", "noaaPrecip.xsl", todayForecast)
logInfo(logName, "Today Precip = " + todayPrecipitation)
val todayTempMax = transform("XSLT", "noaaTempMax.xsl", todayForecast)
logInfo(logName, "Today Temp Max = " + todayTempMax)
val todayTempMin = transform("XSLT", "noaaTempMin.xsl", todayForecast)
logInfo(logName, "Today Temo Min = " + todayTempMin)
// val tomorrowPrecipitation = transform("XSLT", "noaaPrecip.xsl", tomorrowForecast)
// logInfo(logName, "Tomorrow Precip = " + tomorrowPrecipitation)
// val tomorrowTempMax = transform("XSLT", "noaaTempMax.xsl", tomorrowForecast)
// logInfo(logName, "Tomorrow Temp Max = " + tomorrowTempMax)
// val tomorrowTempMin = transform("XSLT", "noaaTempMin.xsl", tomorrowForecast)
// logInfo(logName, "Tomorrow Temo Min = " + tomorrowTempMin)
end
Replace the XX.XXXXXX with your lat and long.
noaaPrecip.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of select="sum(/dwml/data/parameters/precipitation/value)"/>
</xsl:template>
</xsl:stylesheet>
noaaTempMax.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="/dwml/data/parameters/temperature[@type='maximum']/value">
<xsl:sort data-type="number" order="descending"/>
<xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
noaaTempMin.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="/dwml/data/parameters/temperature[@type='minimum']/value">
<xsl:sort data-type="number" order="ascending"/>
<xsl:if test="position()=1"><xsl:value-of select="."/></xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>