FAIL: Yahoo Weather URL in Demo.Items. Need help with HTTP Binding

I’m a newbie to openHAB but not to Home Automation. After familiarizing myself with the available tutorial materials (thank you Kai for the videos) I decided to finally start openHAB using the supplied demo. Immediately it coughed up errors because Yahoo’s “forecastrss” service has been discontinued.

Attempts to use the old RSS service return an XML-formatted error message requesting the use of OAUTH. Encoding the URL using the appropriate OAUTH keys is no longer as trivial as using the old RSS service … so I haven’t bothered to explore this further.

This post offered a solution but it no longer works. It would appear Yahoo has changed things again.

Igor Kromin, has blogged about this issue and has offered a solution using Yahoo Query Language (YQL).

Here’s the URL to get weather data for Montreal using YQL. This works in my browser (MS Edge). Sorry, I had to post it as a non-functional URL because, as new user, I’m limited to 2 links per post.
https:// * from weather.forecast where woeid=3534 and u=‘C’

I used that in demo.items but the HTTP Binding didn’t like it (Invalid URI).

2016-04-21 09:11:48.487 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.lang.IllegalArgumentException: Invalid uri ‘ * from weather.forecast where woeid=3534 and u=‘C’’: Invalid query
at org.apache.commons.httpclient.HttpMethodBase.( ~[na:na]
at org.apache.commons.httpclient.methods.GetMethod.( ~[na:na]
at ~[na:na]
at ~[na:na]
at ~[na:na]
at org.openhab.binding.http.internal.HttpBinding.execute( ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute( ~[na:na]
at org.openhab.core.service.AbstractActiveService$ ~[na:na]

I urlencoded it. This also works in my browser. Again sorry, I had to break this URL to come in under the two-URL limit.
I put that in demo.items and the HTTP Binding couldn’t digest it either (Conversion = ‘2’).

2016-04-21 09:01:54.158 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = '2’
at java.util.Formatter.checkText(Unknown Source) ~[na:1.8.0_77]
at java.util.Formatter.parse(Unknown Source) ~[na:1.8.0_77]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_77]
at java.util.Formatter.format(Unknown Source) ~[na:1.8.0_77]
at java.lang.String.format(Unknown Source) ~[na:1.8.0_77]
at org.openhab.binding.http.internal.HttpBinding.execute( ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute( ~[na:na]
at org.openhab.core.service.AbstractActiveService$ ~[na:na]

I’m stuck. I know the YQL-based URL’s work but there’s something about them that the HTTP Binding doesn’t like. Can anyone shed light on this problem?

Yes, I know I can replace the offending Item in the demo.items file with some other weather service but, gosh-darn it, how will I learn anything that way! :wink:

Did you check this:

Thanks for the prompt reply. Yes, that’s the same thread I linked in my post above. I reported the suggested solution no longer works:

For example:

Results in “Could not connect to the requested server host.”

Ah, yeah, sorry.

Honestly when this failed the first time, I moved to the regular weather binding. Seems to be more stable.

I was tempted to do the same but thought it would be useful to other newbies if I could fix the problem. It’s a better “Out Of Box Experience” to have the demo “Just Work”. Currently, it’s like a new car that instantly illuminates the “Check Engine” light.

Anyway, the experience has led to me to a functional URL (it gets XML-formatted weather from Yahoo).
Unfortunately, the HTTP Binding doesn’t like it. I’m reluctant to dive into the binding’s code and hope someone can simply point out what I’m doing wrong.

How about you share that link with us, and let us have a crack at it? :wink:



Update: I think the BBC’s XML weather service seems promising. Detailed values, no oAuth required, with a simple regex it should be a piece of cake to parse. Also provides worldwide locations. I’ll see what I can knock up tomorrow.

The two bolded URLs in my first post both work in my browser but you first have to remove the space after the "https://". I was obliged to do that in order to get around the forum’s restriction on newcomers like myself (can’t post more than 2 URLs).

Anyhow, here is the reconstituted version:*%20from%20weather.forecast%20where%20woeid%3D3534%20and%20u%3D'C'

It contacts the YQL service and requests select weather.forecast where woeid=3534 and u=‘C’. The HTTP Binding throws up when it attempts to digest the URL.

For my selfish purposes, I could use Environment Canada’s reliable XML feed but it’s of little use to anyone living outside Canada.

FWIW, I checked this BBC page and both of its examples return “Service Temporarily Unavailable”. :frowning:

I found the answer. @maze had a similar problem with the HTTP Binding and @steve1 explained the % had to be escaped. Otherwise, the binding interpreted it as the beginning of a Java format specification.

I replaced all “%” with “%%” and the HTTP binding processed it correctly. However the resulting URL became less legible:

Number Weather_Temperature "Outside Temperature [%.1f °C]" <temperature> (Weather_Chart) { http="<[*%%20from%%20weather.forecast%%20where%%20woeid%%3D3534%%20and%%20u%%3D%%27C%%27:60000:XSLT(yahoo_weather_temperature.xsl)]" }

To improve readability, I replaced all spaces “%%20” with the equally valid “+” and the resulting URL also worked correctly with the HTTP Binding.
Number Weather_Temperature "Outside Temperature [%.1f °C]" <temperature> (Weather_Chart) { http="<[*+from+weather.forecast+where+woeid%%3D3534+and+u%%3D%%27C%%27:60000:XSLT(yahoo_weather_temperature.xsl)]" }


What version of the HTTP binding are you using? Neither my adaptation nor the example you provided work for me.



Update: Actually, never mind. This may be a good solution for the community/demo, but I’m using apache2 as an integral part of the setup anyway, so a simple mod_rewrite rule solves this for me.

For the record, I’m using openHAB 1.8.2 (and the HTTP Binding that comes with it).

Strange; so am I. Well, the problem is solved me, and I have to take care of some other pressing issues today (like failing backups).



Also worked fine for me.

Thanks worked for me

Hello Tara, I use your solution but I have problems with max and min temp. Do you have to change the rules file or the Http binding? And another question about the humidex it works for you?

could someone help me?