[SOLVED] OH1 OpenWeatherMap via http and XSLT - does not work for all items

Tags: #<Tag:0x00007f617ecdb158> #<Tag:0x00007f617ecdb040>

Hello,

I am struggling with OpenWeatherMap data which I get via http request.
I am able to extract the temperature and most other values but neither wind direction (degree) nor visibility but the values are basically available in the XML response (see below).

Here is my configuration.
HTTP in openhab.cfg

http:openWeatherMap.url=http://api.openweathermap.org/data/2.5/weather?id=2812053&appid=<myAPIKEY0>&mode=xml&units=metric
http:openWeatherMap.updateInterval=120000

Here are the items

Group gWeather 	(All)

Group gWeather_Chart_Temp		(gWeather)
Group gWeather_Chart_Wind		(gWeather)
Group gWeather_Chart_Humidity	(gWeather)
Group gWeather_Chart_Pressure	(gWeather)

Number Weather_Temperature 		"Temperatur außen [%.1f °C]"		<temperature>	(gWeather_Chart_temp, gWeather)  		{ http="<[openWeatherMap:60000:XSLT(OWM_weather_temperature.xsl)]" }
Number Weather_Humidity 		"Luftfeuchtigkeit außen [%d %%]"	<humidity>		(gWeather_Chart_humidity, gWeather) 	{ http="<[openWeatherMap:60000:XSLT(OWM_weather_humidity.xsl)]" }
Number Weather_Pressure 		"Luftdruck  [%.0f mbar]"			<pressure>		(gWeather_Chart_pressure, gWeather) 	{ http="<[openWeatherMap:60000:XSLT(OWM_weather_pressure.xsl)]" }
Number Weather_Clouds 			"Bewölkung [%.0f %%]"				<sun_clouds>	(gWeather) 	   			 	 	 	 	{ http="<[openWeatherMap:60000:XSLT(OWM_weather_clouds.xsl)]" }
Number Weather_Visibility 		"Sicht  [%.1f km]"					<eye>			(gWeather) 	  	 	 		 	 	 	{ http="<[openWeatherMap:60000:XSLT(OWM_weather_visibility.xsl)" }
Number Weather_Windspeed 		"Windgeschwindigkeit [%.0f km/h]"	<wind>			(gWeather_Chart_wind, gWeather) 	 	{ http="<[openWeatherMap:60000:XSLT(OWM_weather_wind_speed.xsl)]" }
String Weather_Winddirection 	"Windrichtung [%s]"					<winddirection>	(gWeather)  	 	 	 	 	 		{ http="<[openWeatherMap:60000:XSLT(OWM_weather_wind_direction.xsl)]" }
Number Weather_Winddegree 		"Windrichtung [%.0f °]"				<winddirection>	(gWeather)  	   			 	 		{ http="<[openWeatherMap:60000:XSLT(OWM_weather_wind_degree.xsl) }" }

among this items only Weather_Visibility and Weather_Winddegree are not extracted from the XML response which looks like this

<current>
	<city id="2812053" name="Weissach">
		<coord lon="8.93" lat="48.85"/>
		<country>DE</country>
		<sun rise="2017-07-16T03:38:52" set="2017-07-16T19:21:20"/>
	</city>
	<temperature value="23.24" min="22" max="24" unit="metric"/>
	<humidity value="41" unit="%"/>
	<pressure value="1023" unit="hPa"/>
	<wind>
		<speed value="2.6" name="Light breeze"/>
		<gusts/>
		<direction value="340" code="NNW" name="North-northeast"/>
	</wind>
	<clouds value="0" name="clear sky"/>
	<visibility value="10000"/>
	<precipitation mode="no"/>
	<weather number="800" value="clear sky" icon="01d"/>
	<lastupdate value="2017-07-16T17:50:00"/>
</current>

Here are the ssl-files as example for temperature (works well)

<?xml version="1.0"?>
<xsl:stylesheet 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:output indent="yes" method="xml" encoding="UTF-8" omit-xml-declaration="yes" />

	<xsl:template match="/">
		<xsl:value-of select="/current/temperature/@value" />
	</xsl:template>

</xsl:stylesheet>

and here the xsl-file for wind degree which does not work

<?xml version="1.0"?>
<xsl:stylesheet 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:output indent="yes" method="xml" encoding="UTF-8" omit-xml-declaration="yes" />

	<xsl:template match="/">
		<xsl:value-of select="/current/wind/direction/@value" />
	</xsl:template>

</xsl:stylesheet>

The error message from the log file is

10:32:54.990 ERROR o.o.m.i.i.GenericItemProvider[:343]- Binding configuration of type 'http' of item ‘Weather_Winddegree‘ could not be parsed correctly.
org.openhab.model.item.binding.BindingConfigParseException: bindingConfig '<[openWeatherMap:60000:XSLT(OWM_weather_wind_degree.xsl) }' doesn't contain a valid binding configuration
	at org.openhab.binding.http.internal.HttpGenericBindingProvider.parseBindingConfig(HttpGenericBindingProvider.java:143)
	at org.openhab.binding.http.internal.HttpGenericBindingProvider.processBindingConfiguration(HttpGenericBindingProvider.java:119)
	at org.openhab.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:341)
	at org.openhab.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:302)
	at org.openhab.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Why?

Any idea?

Regards,
Axel

PS: I also restarted openHAB ;-).
I run openHAB1.8.2 on QNAP (TS-419P).
I switched back from OH2.0.0-3 as there are to many restrictions on QNAP systems at the moment.

You are missing the closing ] in your binding for the Item.

Since you are on 1.8, the old openHAB Designer would have pointed this error out to you.

Weather_Winddegree is also missing the closing ].

OHHH, want a stupid error.
Thank you very much for the hint.
I am using the openHAB Designer 1.8.3 for Mac but it did not tell me anything about this error.

Axel