[SOLVED] Calling the free OpenWeatherMap API with the OpenWeatherMap Binding

I’m rather new to openHAB and setting up smart things around my home. Recently I tried to tackle weather forecasts and implementing them in a HABPanel, which brings me to a problem I encountered:

I’m using the OpenWeatherMap Binding and set it up according to the documentation and this post. This means:

I have a thing (combination of Bridge and Thing):

Bridge openweathermap:weather-api:api   "OpenWeatherMap Account"        [apikey="XXX", refreshInterval=10, language="de"] {
    Thing weather-and-forecast local     "Local Weather And Forecast"     [location="X.XX, X.XX", forecastHour=120, forecastDays=0]

and many items. I will post examples of the temperature item series:

Number:Temperature		Weather_OWM_Temp_h3		    "Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours03#temperature"}
Number:Temperature		Weather_OWM_Temp_h6		    "Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours06#temperature"}
Number:Temperature		Weather_OWM_Temp_h9		    "Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours09#temperature"}
Number:Temperature		Weather_OWM_Temp_h12		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours12#temperature"}
Number:Temperature		Weather_OWM_Temp_h15		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours15#temperature"}
Number:Temperature		Weather_OWM_Temp_h18		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours18#temperature"}
Number:Temperature		Weather_OWM_Temp_h21		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours21#temperature"}
Number:Temperature		Weather_OWM_Temp_h24		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours24#temperature"}
Number:Temperature		Weather_OWM_Temp_h27		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours27#temperature"}
Number:Temperature		Weather_OWM_Temp_h30		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours30#temperature"}
Number:Temperature		Weather_OWM_Temp_h33		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours33#temperature"}
Number:Temperature		Weather_OWM_Temp_h36		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours36#temperature"}
Number:Temperature		Weather_OWM_Temp_h39		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours39#temperature"}
Number:Temperature		Weather_OWM_Temp_h42		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours42#temperature"}
Number:Temperature		Weather_OWM_Temp_h45		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours45#temperature"}
Number:Temperature		Weather_OWM_Temp_h48		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours48#temperature"}
Number:Temperature		Weather_OWM_Temp_h51		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours51#temperature"}
Number:Temperature		Weather_OWM_Temp_h54		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours54#temperature"}
Number:Temperature		Weather_OWM_Temp_h57		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours57#temperature"}
Number:Temperature		Weather_OWM_Temp_h60		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours60#temperature"}
Number:Temperature		Weather_OWM_Temp_h63		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours63#temperature"}
Number:Temperature		Weather_OWM_Temp_h66		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours66#temperature"}
Number:Temperature		Weather_OWM_Temp_h69		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours69#temperature"}
Number:Temperature		Weather_OWM_Temp_h72		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours72#temperature"}
Number:Temperature		Weather_OWM_Temp_h75		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours75#temperature"}
Number:Temperature		Weather_OWM_Temp_h78		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours78#temperature"}
Number:Temperature		Weather_OWM_Temp_h81		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours81#temperature"}
Number:Temperature		Weather_OWM_Temp_h84		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours84#temperature"}
Number:Temperature		Weather_OWM_Temp_h87		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours87#temperature"}
Number:Temperature		Weather_OWM_Temp_h90		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours90#temperature"}
Number:Temperature		Weather_OWM_Temp_h93		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours93#temperature"}
Number:Temperature		Weather_OWM_Temp_h96		"Temperature [%.1f %unit%]" <temperature>		{channel="openweathermap:weather-and-forecast:api:local:forecastHours96#temperature"}

Like bastiaan_van_h suggested temperature data is called in 3 hour intervals for the next 96 hours. This is done to make use of the OWM free API in his widget. The Bridge is online (according to console), thing and items are also accepted without errors in the Console. I set the console to DEBUG for the OWM Binding. So far so good, BUT I only get data from OWM for the first 4 items of the temperature series (same for humidity etc.). Here are the console entries. Every 10 mins an update as set in the Bridge:

2019-09-27 11:31:26.891 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h3 changed from 17.22 °C to 17.37 °C

2019-09-27 11:31:26.897 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h6 changed from 18.12 °C to 18.24 °C

2019-09-27 11:31:26.906 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h9 changed from 16.53 °C to 16.61 °C

2019-09-27 11:31:26.916 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h12 changed from 15.83 °C to 15.87 °C
2019-09-27 11:41:27.303 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h3 changed from 17.37 °C to 17.52 °C

2019-09-27 11:41:27.304 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h6 changed from 18.24 °C to 18.35 °C

2019-09-27 11:41:27.305 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h9 changed from 16.61 °C to 16.69 °C

2019-09-27 11:41:27.306 [vent.ItemStateChangedEvent] - Weather_OWM_Temp_h12 changed from 15.87 °C to 15.91 °C

I tried a few things I could think of to get the bottom of this:

  • Changing the API Key

Tried with a second API Key, but no change in behavior.

  • Changing the channel settings “forecastHour=X, forecastDays=X”.

As the Daily Forecast is not supported by the free API setting “forecastDays” to any value higher than “0” will result in an errer in the console (> invalud api key). I also reached out to OWM and confirmed that requesting data in this fashion, 3 hour intervals for the next 5 days, is possible with the free API:

“You should be able to get 40 forecasts periods with 3-hour step (5 days)”

I tried this out by calling the forecast with


Indeed data for 40 forecasts is returned, which is equal to 120 hours / 5 days, as expected. (even more then bastiaan_van_h incorporated in his widget.
Reducing the “forecastHour” to e.g. 24/48 or increasing it to the maximal 120, did not change the behavior.

  • Checking things and items

I checked and double checked my things and items, but cannot find any reason only the first 4 items are populated with data. Especially since there is no error returned in the console.

Since I could not find a post in the forum describing this problem I opened a new topic.

Thanks for any help or suggestions!This text will be hidden

What does the > Sign at the end of the Thing stands for ? Is there a curly brace ( } ) at the end of file ?

Mine looks like:

Bridge openweathermap:weather-api:api "OpenWeatherMap Account" [apikey="your api key", refreshInterval=30, language="de"] {
     Thing weather-and-forecast local "Local Weather And Forecast" [location="xx.xxxxx,y.yyyyy,zzz", forecastHours=120, forecastDays=0]
     Thing uvindex              local "Local UV Index"             [location="xx.xxxxx,y.yyyyy", forecastDays=7]

Yes, it’s correct that one can get the forecasts up to hour 120 from current (5 days) in 3-hour steps.

Ah. That was a typo (I edited the initial post). There is no > Sign and a curly brace at the end in my .things file, too. So basically looks like yours except for the uvindex.

I see you changed the the .things-file. What does PaperUI shows for the Thing ?

and the Thing itself from current

to the highest

1 Like

There we go!

In PaperUI the interval for weather data was set to the default value and not updated from what I defined .things file.

The reason is rather simple… My things file said forecastHour and not frecastHours.

My bad. Thank you for your help!

1 Like