Hello Guys,
I want to set my ambient lighting with a weather forecast response with the Yahoo YQI.
Therefore im trying to get a JSON response from the Yahoo weather server using this poll request:
Using JSONPATH I can isolate a single number (forecast code for tomorrow) : $..forecast[1].code This is the weather code reference
Installed the HTTP binding and the JSONPATH conversion. I am trying to put my Number in an item directly with:
This does not work and I can’t figure out why. I also tried to pull the data in a rule like this:
import org.openhab.core.library.types.*
import org.opemhab.core.types.*
import org.openhab.model.script.actions.*
rule "Wettersauele"
when
Item Wettervorhersage changed from OFF to ON
//Time cron "0 0 16 1/1 * ? *"
then
logInfo("wetter","Binding Running")
var String json = sendHttpGetRequest("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22orsbach%2Cgermany%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys")
var String value = transform("JSONPATH", "$..forecast[1].code", json)
logInfo(json)
logInfo(value)
end
But that does not work aswell, Giving me the Error “Error while executing script” … “index=1,size=1”.
Hm… anyone of you guys got an idea how to fix this error?
No answer from me, just a question.
Why are you trying to isolate a value from the weather report by yourself? There is a weather binding which does that for you.
I tried to figure out how to get a condition forecast but afaik this is not possible with these.
Yahoo gives me 49 different condition forecasts for the next 7 days and they are there, but I can’t grab them
Similar actions have been done in openhab several times but they are not working for me…
The tree address for the code information is: query.results.channel.item.forecast[x].code Are you sure you can concatenate your request to only $..forecast[1].code ?
Are you looking for the weather condition converted to a number?
That would be the “id” in the weather binding!
You just need the correct woeid for your place.
Well I did move my openHab server yesterday and I somehow managed to get it to work.
Sadly though I read your reply afterwards, but I will stick to my solution because it costed lots of effort - thanks anyway !!
rule “Wettersauele”
when
Time cron "0 0 17 1/1 * ? *" and
Item Wettervorhersage is ON or
Item dummy1234 changed from OFF to ON and
Item Wettervorhersage is ON
If it works for you, everything is fine. Thanks for the feedback.
P.S.:In case your problem is solved you can either edit the thread title to show something like: “[solved] …” or use the “This reply solves the problem” button in one of the replys( your own) to show that in the initial post.