home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.11k stars 29.79k forks source link

Netatmo integration cannot go trough add process #103867

Closed bvalat closed 10 months ago

bvalat commented 10 months ago

The problem

When i click on Add integration and validate, it opens the netatmo website to grant permission on my devices. If i click on Yes I agree, the webite loops on itself (I see activity on the browser tab) so i can't finish the process of adding it... It seems that the callback URI is never called if i agree. Only if i cancel it redirects me on https://account-link.nabucasa.com/ I see someone having the same problem on the forum : https://community.home-assistant.io/t/netatmo-integration-not-working-on-2023-11/639754

What version of Home Assistant Core has the issue?

core-2023.11.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Netatmo

Link to integration documentation on our website

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

Diagnostics information

No log since the problem seems to be beteewn https://auth.netatmo.com/ and nabucasa.com

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Brand new HAOS installation on RPI3 I only own a netatmo weather station with temp modules and rain meter. Tried with Chrome, Edg,firefox and Opera web browser. When i authenticate, the netatmo website opens https://home.netatmo.com/security intead of previously https://my.netatmo.com/app/station. Maybe legrand/netatmo broke something?

home-assistant[bot] commented 10 months ago

Hey there @cgtobi, mind taking a look at this issue as it has been labeled with an integration (netatmo) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `netatmo` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign netatmo` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


netatmo documentation netatmo source (message by IssueLinks)

Jimmylet commented 10 months ago

Hi! Same problem here :)

robinoux commented 10 months ago

same here ;)

cgtobi commented 10 months ago

Are you using the external or internal HA instance URL/IP address when configuring the integration?

Jimmylet commented 10 months ago

Internal. It’s a new installation of HA for me.

bvalat commented 10 months ago

same here i use http://homeassistant.local:8123/

LeonardoHSilva commented 10 months ago

Same here

cgtobi commented 10 months ago

Please try again with your public URL.

bvalat commented 10 months ago

What public URL? As i said i'm brand new to home assistant. Is it necessary to have a plublic URL? All other cloud based integration didn't neeed that and i do not see that on netatmo integration's documentation

robinoux commented 10 months ago

With my public URL, le problem is the same...

leule7 commented 10 months ago

I have exactly the same problem - start netatmo integration, the website is called up and after clicking yes it is only updated. url auth.netatmo.com. Third party appz set up in the dev account. When integrating into HA, I'm missing the dialog with which to enter the client ID and client secret.

pulsebreaker commented 10 months ago

I had exactly the same issue on a newly installed HA. As of today it doesn't send me to the Netatmo page anymore, I just get this:

Screenshot 2023-11-13 193357

Hope it helps.

leule7 commented 10 months ago

I had exactly the same issue on a newly installed HA. As of today it doesn't send me to the Netatmo page anymore, I just get this: Screenshot 2023-11-13 193357

Hope it helps.

I get that picture too. Restarting home assistant helps me. Then I get the query again for the website auth.netatmo.com, which then doesn't work properly

pulsebreaker commented 10 months ago

That's good to know. Thanks.

leule7 commented 10 months ago

If I take a closer look at the URL, I can find the home assistant cloud nabu casa:

account-link.nabucasa.com

Does this mean that the netatmo integration only works with the paid home assistant cloud nabu casa? Maybe someone with an active cloud (nabu casa) can test whether it works!?

Then I also notice that the client_id doesn't match mine under the netatmo dev account. If I then replace the ID with mine in the URL, that doesn't help either.

I hope this helps a little

MOTCH21300 commented 10 months ago

Moi c'est pareil et j'ai un cloud actif (75 EURO) alors j'aimerai que cela marche. c'est pas la peine de payer un service si il ne marche pas!!!!!!

bvalat commented 10 months ago

For non french speaking people, the post above complains about Netatmo integration not working even with the paid cloud of home assistant.

leule7 commented 10 months ago

same topic:

https://community.home-assistant.io/t/netatmo-integration-not-working-on-2023-11/639754

edouardmisset commented 10 months ago

I seem to have the same issue

It might be related to this log message:

Logger: pyoverkiz.enums.protocol
Source: runner.py:188
First occurred: 23:34:58 (9 occurrences)
Last logged: 23:34:58

Unsupported protocol netatmo has been returned for <enum 'Protocol'>
michael-k4i commented 10 months ago

for information it works well on a newly installed Home Assistant 2023.6.3 on CasaOS

leule7 commented 10 months ago

maybe he can help us https://github.com/jbouwh but I don't know how to contact him since I don't have twitter (x).

FranzStrudel commented 10 months ago

@jbouwh

Pinging you in the behalf of @leule7

Itsie commented 10 months ago

same issue here, any solution right now?

deosrc commented 10 months ago

I'm not sure what is causing this but setting up a custom application using the instructions at https://next.home-assistant.io/integrations/netatmo#development--testing-with-your-own-client-id seems to have worked for me. I've not checked this very thoroughly though. Obviously this isn't a good solution, but it might help find the problem.

cgtobi commented 10 months ago

@deosrc that is a very helpful information and hints at the extend scope to support certain BTicino devices.

deosrc commented 10 months ago

@cgtobi Looks like that's the problem. It succeeds when the new scopes added to the pyatmo library are removed. I expect it would be better to list only the required scopes within the HA code rather than filtering out specific scopes.

https://github.com/home-assistant/core/blob/2d39eaf0a21e9a4cb148aa7f1791bcc34e94aea9/homeassistant/components/netatmo/__init__.py#L155-L162

As an easier workaround than creating the application credentials, when the netatmo authorization page opens, change the URL by removing read_mhs1%2B and write_mhs1%2B.

deosrc commented 10 months ago

@leule7 Interesting. Maybe I did something different before. When I remove those parts of the URL and click accept, it loops back around to the page. When I click accept again it succeeds. I'm on a modified version of Home Assistant at the moment though while I'm trying some things so that might be affecting it.

leule7 commented 10 months ago

I'm not sure what is causing this but setting up a custom application using the instructions at https://next.home-assistant.io/integrations/netatmo#development--testing-with-your-own-client-id seems to have worked for me. I've not checked this very thoroughly though. Obviously this isn't a good solution, but it might help find the problem.

year, very good, that works...

In Home Assistant navigate to Settings -> Devices & Services Click on the three dots (menu) at the top right and then login information for the application.

Add application credentials

then from https://dev.netatmo.com/ ... my apps add the client_id and client_secret information in application credentials in home assistant.

If the netatmo integration is now added, another dialog will appear. Use the new application credentials there and not those from Home Assistant Cloud.

Thank you

FranzStrudel commented 10 months ago

The redirect_uri is mapped to account-link.nabucasa.com.

Is an nabucasa account needed ? I don´t have one, neither do I want it. My HA is already available publicly, and the redirect_uri should be map to my instance.

I tried to changed it manually, but I get an uri mismatch error

robinoux commented 10 months ago

for me it said : ok the account is just relink. But i didnt see netatmo in my integration

bvalat commented 10 months ago

Good point, why the redirect url is account-link.nabucasa.com? In fact the integration doesn't need to be publicly available. I crested an app on my netatmo account and add credentials as deosrc suggested. It works and my HA is not publicly available.

rheuft commented 10 months ago

@cgtobi Looks like that's the problem. It succeeds when the new scopes added to the pyatmo library are removed. I expect it would be better to list only the required scopes within the HA code rather than filtering out specific scopes. https://github.com/home-assistant/core/blob/2d39eaf0a21e9a4cb148aa7f1791bcc34e94aea9/homeassistant/components/netatmo/__init__.py#L155-L162

As an easier workaround than creating the application credentials, when the netatmo authorization page opens, change the URL by removing read_mhs1%2B and write_mhs1%2B.

Unfortunately, removing read_mhs1%2B and write_mhs1%2B in the url didn't work for me e

Removing from the URL didn't work for me either, somehow I don't have read_mhs1%2B and write_mhs1%2B in my URL. Should I go on with creating app credentials as a solution?

deosrc commented 10 months ago

I don't believe a nabu casa account is required. The reason for Nabu Casa in the redirect url is for ease of use to avoid each user having to register for a developer account.

https://developers.home-assistant.io/docs/config_entries_config_flow_handler#configuration-via-oauth2

The built-in OAuth2 support works out of the box with locally configured client ID / secret using the Application Credentials platform and with the Home Assistant Cloud Account Linking service. This service allows users to link their account with a centrally managed client ID/secret.

leule7 commented 10 months ago

@cgtobi Looks like that's the problem. It succeeds when the new scopes added to the pyatmo library are removed. I expect it would be better to list only the required scopes within the HA code rather than filtering out specific scopes. https://github.com/home-assistant/core/blob/2d39eaf0a21e9a4cb148aa7f1791bcc34e94aea9/homeassistant/components/netatmo/__init__.py#L155-L162

As an easier workaround than creating the application credentials, when the netatmo authorization page opens, change the URL by removing read_mhs1%2B and write_mhs1%2B.

Unfortunately, removing read_mhs1%2B and write_mhs1%2B in the url didn't work for me e

Removing from the URL didn't work for me either, somehow I don't have read_mhs1%2B and write_mhs1%2B in my URL. Should I go on with creating app credentials as a solution?

creating app credentials works in my case

jbouwh commented 10 months ago

@jbouwh

Pinging you in the behalf of @leule7

Not sure how I can help?

deosrc commented 10 months ago

I have a fix for this working locally. Should have a PR shortly.

leule7 commented 10 months ago

@jbouwh Pinging you in the behalf of @leule7

Not sure how I can help?

It's settled, but thank you very much for the quick response. :-)

cgtobi commented 10 months ago

Please people, do refrain from tagging random devs out of the blue just to get attention. This is what code owners are for and they are tagged automatically.

cgtobi commented 10 months ago

@deosrc let me know if you need support or a review. Feel free to ping me on discord.

deosrc commented 10 months ago

@deosrc let me know if you need support or a review. Feel free to ping me on discord.

Thanks @cgtobi. I've had to leave this for today. The changes are at https://github.com/deosrc/homeassistant-core/tree/fix/netatmo-auth if you want to pick it up? I modified it in a way that means new scopes added to the library won't break it again. Hopefully that makes sense. I tested locally and all seems to be working with both cloud and application credentials. I added unit tests for the new method but not sure if they're working.

If you want to leave it for me I'll try pick it up tomorrow.

MOTCH21300 commented 10 months ago

Bonjour, Aujourd'hui j'ai restauré une version antérieure de home assistant et l'intégration de netatmo a fonctionné Je ne sais pas si ça vient de ça mais ça marche !

cgtobi commented 10 months ago

@deosrc I made a few changes that I'd suggest you'd incorporate. https://github.com/deosrc/homeassistant-core/pull/1 Thanks for your work. Greatly appreciated.

Marcel030nl commented 9 months ago

I pulled the dev version of Home Assistant and I can confirm it's working again. I could link a new Netatmo account to a new instance without using a Nabu Casa url. Great work!

deosrc commented 9 months ago

This has been included in the 2023.11.3 version just released.

https://www.home-assistant.io/blog/2023/11/01/release-202311/#release-2023113---november-22

michael-k4i commented 9 months ago

This has been included in the 2023.11.3 version just released.

https://www.home-assistant.io/blog/2023/11/01/release-202311/#release-2023113---november-22

And it works well, thanks

jaal2001 commented 8 months ago

Anyone having the same issue again with 2023.12.1? I'm trying to add Netatmo, but even when the NabuCasa website appears, the integration still does not show up. Logfile does not show any hint so far.

deosrc commented 8 months ago

...but even when the NabuCasa website appears...

@jaal2001 I'm not sure what you mean by this. Do you mean the My Home Assistant page?

After you login at Netatmo, it will redirect you to My Home Assistant which then needs to redirect you to your Home Assistant instance I believe. If you don't have my home assistant configured, it doesn't know where to send you so can't complete authentication.

https://my.home-assistant.io/

jaal2001 commented 8 months ago

...but even when the NabuCasa website appears...

@jaal2001 I'm not sure what you mean by this. Do you mean the My Home Assistant page?

After you login at Netatmo, it will redirect you to My Home Assistant which then needs to redirect you to your Home Assistant instance I believe. If you don't have my home assistant configured, it doesn't know where to send you so can't complete authentication.

https://my.home-assistant.io/

That is configured. I've tried both methods: The native integration and also providing own credentials. Both do not lead to the integration showing up.

cgtobi commented 8 months ago

Does your browser block popups? Have you tried a different browser/device?

jaal2001 commented 8 months ago

Yeah, I tried that. Each time the plugin redirects me to the Netatmo website and in the end Home Assistant tells me "Successfully reauthenticated". But under "Integrations" Netatmo never shows up.