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:// query.yahooapis.com/v1/public/yql?q=select * 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 ‘https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid=3534 and u=‘C’’: Invalid query
at org.apache.commons.httpclient.HttpMethodBase.(HttpMethodBase.java:222) ~[na:na]
at org.apache.commons.httpclient.methods.GetMethod.(GetMethod.java:89) ~[na:na]
at org.openhab.io.net.http.HttpUtil.createHttpMethod(HttpUtil.java:337) ~[na:na]
at org.openhab.io.net.http.HttpUtil.executeUrl(HttpUtil.java:167) ~[na:na]
at org.openhab.io.net.http.HttpUtil.executeUrl(HttpUtil.java:133) ~[na:na]
at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:164) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[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.
https:// query.yahooapis.com/v1/public/yql?q=select%20%20from%20weather.forecast%20where%20woeid%3D3534%20and%20u%3D%27C%27*
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(HttpBinding.java:139) ~[na:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) ~[na:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) ~[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?

PS
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:
http://xml.weather.yahoo.com/forecastrss?w=3534&u=c

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:

Cheers,

PelliX

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:

https://query.yahooapis.com/v1/public/yql?q=select%20*%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.

Addendum
For my selfish purposes, I could use Environment Canada’s reliable XML feed but it’s of little use to anyone living outside Canada.
http://dd.weatheroffice.ec.gc.ca/citypage_weather/xml/QC/s0000635_e.xml

FWIW, I checked this BBC page and both of its examples return “Service Temporarily Unavailable”. :frowning:
https://support.bbc.co.uk/platform/feeds/WeatherFeeds.htm

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="<[https://query.yahooapis.com/v1/public/yql?q=select%%20*%%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="<[https://query.yahooapis.com/v1/public/yql?q=select+*+from+weather.forecast+where+woeid%%3D3534+and+u%%3D%%27C%%27:60000:XSLT(yahoo_weather_temperature.xsl)]" }

4 Likes

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

Thanks,

PelliX

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).

Cheers,

PelliX

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?