Accessing Weather underground values

Is there a way to access data from the weather underground API in openhab for the txt_forecast rather than just the simpleforecast?

I’d like to get the fcttext data into openhab to show a nice informative forecast of the day rather than just ‘Overcast’ that comes from the conditions parameter in simpleforecast.

For some extra info, if you check out the 10 day forecast xml below it appears that openhab can only get data from the simpleforecast section and ignores the txt_forecast entirely.

Http://api.wunderground.com/api/your API key/forecast10day/q/Australia/PWS:IQUEENSL470.xml

Ive tried a stack of different property and forecast values but can’t seem to figure it out.

Thanks!

1 Like

You could use the HTTP binding and an XSLT transform:

String fcttext_0 "[%s]" { http="<[http://api.wunderground.com/api/your API key/forecast10day/q/Australia/PWS:IQUEENSL470.xml:300000:XSLT(wunderground_10day_fcttext.xsl)]" }

wunderground_10day_fcttext.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="text" indent="no" encoding="UTF-8" omit-xml-declaration="yes" />
	<xsl:template match="/">
		<xsl:value-of select="normalize-space(//forecastdays/forecastday[1]/fcttext)"/>
	</xsl:template>
</xsl:stylesheet>

produces:

Clouds early, some clearing late. Lows overnight in the upper 60s.
2 Likes

Brilliant. Thank you. I started down this path but haven’t used the transformations any further than copying code around, i’m starting to get the format after using your example, works well.

It would be nice if the full set of requests were in the weather binding.

You’re welcome!

As nice as the weather binding is, there is just so much data to potentially normalize across the various providers that I decided to stay with the HTTP binding and transformations for my needs. Plus, where I live, there is a comparatively small weather API provider that provides superior quality forecasts but is not supported by the binding, so scraping it out using JSONPATH or XSLT is my only option anyway (or live with poor quality forecasts from the supported sources).