[SOLVED] Can't retrieve OpenWeatherMap data. Invalid API key

Dear Everyone!

I have changed from Yahoo to OpenWeatherMap, because Yahoo was really unrealiable and stopped working completely in the last days.
OpenWeatherMap seems good for me, I have created an account, got an API key. If I issue an API call with my key, it works perfectly. OpenHab also shows all the data.

However I get this error every time…

Can't retreive weather data: Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.

Does anyone know why?

Thanks!

Hi Kristof,

do you use the new OpenWeatherMap binding or the existing weather binding?

Hi!

I’m using the Weather binding

Are you trying to access forecast data?

Yes, I have some item… Forecast Temperature, Temperature feel, Condition, Visibility, etc… But none of them gets null or not updating, I can see all item states…

This is because the api/access has changed, use the new binding

That is the reason for the message you can see in your log file. The forecast of the Weather binding uses the daily forecast API of OWM. This is not free for everyone, you have to purchase at least a Startup license to use it. Unfortunately the Weather binding does not support the free hourly forecast API. I like to invite you to have a look into the new OWM binding. It supports both forecast versions. Switching to it will cost some time, but there are new features which are worth the effort.

Thanks, I’ll change the binding

I have tried the binding. I have added a bridge with my API key, but it stays offline. However after adding it, in the inbox Current Weather and 3 hour forecast showed up, but when I added it, it stayed offline…

The things should tell you why they stay offline. Did you looked into your event.log or openhab.log files?

I have tried it, when I add the item, I get this in the log:

2018-09-04 21:56:28.206 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'openweathermap:weather:api:local' to inbox.

==> /var/log/openhab2/events.log <==

2018-09-04 21:56:28.268 [home.event.InboxAddedEvent] - Discovery Result with UID 'openweathermap:hourly-forecast:api:local' has been added.

==> /var/log/openhab2/openhab.log <==

2018-09-04 21:56:28.267 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'openweathermap:hourly-forecast:api:local' to inbox.


When I enter the API key, only this what I can see in the log…

2018-09-04 21:58:54.387 [me.event.ThingUpdatedEvent] - Thing 'openweathermap:weather-api:api' has been updated.

2018-09-04 21:58:54.401 [hingStatusInfoChangedEvent] - 'openweathermap:weather-api:api' changed from UNINITIALIZED (HANDLER_CONFIGURATION_PENDING) to INITIALIZING

2018-09-04 21:58:54.411 [hingStatusInfoChangedEvent] - 'openweathermap:weather-api:api' changed from INITIALIZING to UNKNOWN

A minute later…

2018-09-04 21:59:54.412 [hingStatusInfoChangedEvent] - 'openweathermap:weather-api:api' changed from UNKNOWN to OFFLINE

The API thing stays offline as long as no other thing has been added. Try to add the current weather or the hourly forecast thing and wait for the next refresh - default value is 60min. To speed up the refresh you can edit the API thing configuration after adding another thing. This will reinitialize the connection to the API.

Thanks, I have changed the refresh to 10 min, so I’ll wait and see if it makes any change… I have added a Current Weather thing which is linked to the API thing

Evening gentleman,

I have exactly the same problem with Invalid API key while all the values are still being updated as expected on OH. So I have followed advices and installed owm later addon (jar file) as still using OH 2.3.0.

Looking at this new OWM binding I can tell that it has a lot of information and probably I will only be interested with few items instead of everything (free stuff :grinning:)

Below is the list of my current channels which I would like to continue updating with new binding.

Out%20temp

Just want to be make sure that each of these channels are available on free account. So would you be able to confirm which of these items are free please and if you would be able to drop me items from the demo that would be fab.

Many thanks

The new OWM supports units of measurement for the number channels.
I’m not sure that works in OH2.3??

Just copy/edit the selected localCurrentxxx Items you want from the copious examples in the docs

Thanks @rossko57

Forgot to mention that I can only see the following channels under “current weather” section. As you can see the current temperature is not there :disappointed:

Older versions (e.g. for OH2.3 release) are not supported anymore.

That explains All - thank you. I have reason to further delay the upgrade to version 2.4.0 any longer. Got myself a weekend task :grinning:

openHAB 2.4
Ubuntu 18.04 (lxd/lxc container)
I have experienced the same issue with the Weather Binding and OpenWeatherMap as a provider (API error messages in the log). After switching to ForecastIo / Dark Sky API, everything works fine, no error messages related to API. Dark Sky free API is much more generous than OpenWeatherMap’s one.
When I added location, e.g. location my-home. in weather.cfg (/etc/openhab2/services) and later on changed it to location.home my openhab.log has been flooded with errors, like "there is no location my-home". For some reasons, /var/lib/openhab2/config/org/openhab/weather.cfg contains all old, removed from the /etc/openhab2/services/weather.cfg, records. After cleaning it, my weather binding works as expected.
Just in case, if someone, like I was, is struggling with the html part, which is really nice when it works and added to the HABpanel as a frame widget:

  1. /var/lib/openhab2/webapps/weather-data/layouts/example.html
  2. /etc/openhab2/html/weather-data/images
  3. /etc/openhab2/html/weather-data/layouts

example.html (in both locations):
prepend /static/ to everything that starts with /weather-data (href, src)

Do we really need all that weather provided info for the home automation projects?

It’s up to you.
However you should use the new 2.X bindings. Darksky (if I’m right) and also OpenWeatherMap has it’s own new binding which works fine…