core: Openweathermap intergration invalid key

The problem

I have registerd an account at openweathermap and generated 2 API keys (to be sure that the api key is working i have generated a secondary key, both are not working even after two days) two days ago. Since generation everytime i try to configure the integration i got the message “Invalid API key”

Home Assistant 2022.8.5 Supervisor 2022.08.3 Operating System 8.4 Frontend 20220802.0 - latest

What version of Home Assistant Core has the issue?

2022.8.5

What was the last working version of Home Assistant Core?

2022.8.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

openweathermap

Link to integration documentation on our website

https://www.home-assistant.io/integrations/openweathermap/

Diagnostics information

no related information in the logs. The integration is not installed as long as the key is not working!

Example YAML snippet

i dont have any extra configuration.

Anything in the logs that might be useful for us?

no logging belonging to this issue, i'm not sure if the following log entry belongs to this issue? This message does not appears every time i try configure the new integration, so i'm not sure if this is coused by the "invalid api key" problem.

2022-08-18 07:49:59.722 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [139772116061296] Connection closed by client
2022-08-18 07:50:11.657 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139772113221376] Error handling message: Unauthorized (unauthorized)

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (1 by maintainers)

Most upvoted comments

2022.9.1 has a patch that allows the free plan to be used. Only the hourly mode is supported using new generated keys, from a recent account.

Same I tried integrating this last week without any success.

On Wed, Sep 7, 2022 at 9:12 AM DaHype @.***> wrote:

Seems so, i think you have right with “new people”. Because i use and try it only since 2 weeks.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/76966#issuecomment-1239447282, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJQ3NWLMHCYO5Y52O2P2VADV5CPFXANCNFSM5634LSGQ . You are receiving this because you commented.Message ID: @.***>

This is definitely an issue. Maybe it only effects new people trying to integrate? I saw somewhere that the API has changed to a v 3.0 over the 2.5 version? Is this true and is this maybe a reason? @jbouwh @DaHype see this thread.

Hey folks, I’ve got the same issue. I think the source of the problem is here:

File: https://github.com/home-assistant/core/blob/dev/homeassistant/components/openweathermap/config_flow.py Lines: 131-133

async def _is_owm_api_online(hass, api_key, lat, lon):
    owm = OWM(api_key).weather_manager()
    return await hass.async_add_executor_job(owm.one_call, lat, lon)

This is what appears to be the validation of the key against the service during the configuration setup. As you can see, the owm.one_call, lat, lon client call uses the “one_call” method of the OWM client lib. However as you can see here from the library documentation, using the “one_call” method requires a paid key.

My suggestion would be to use the appropriate method owm.weather_at_coords, lat, lon as defined here in the library docs; in order to validate the API Key.

Can any maintainers (@fabaff ?) validate my assertion and possibly implement the fix?

Interesting. I have the same problem here.

It’s not this, the onecall API is just being used as an example on the page you linked to. You can have 1000 free onecall API calls per day (https://openweathermap.org/price)

The problem is that new API keys are using onecall 3.0 and pyowm hasn’t been updated to use this new API yet (it’s on 2.5) so we’re waiting for this to be updated.