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
73.43k stars 30.67k forks source link

Netatmo issue when reauthenticating with Home Assistant Cloud #79326

Closed cokeman0 closed 2 years ago

cokeman0 commented 2 years ago

The problem

After upgrading to b0, netatmo wanted to reauth. after several failed attempts, I not get this message in the netatmo integration

Forsøger konfigurationen igen: 500, message='Internal Server Error', url=URL('https://account-link.nabucasa.com/refresh_token/netatmo')

What version of Home Assistant Core has the issue?

2022.10.0b0

What was the last working version of Home Assistant Core?

2022.09.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Netatmo

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:395
First occurred: 22.05.17 (1 occurrences)
Last logged: 22.05.17

Config entry 'Home Assistant Cloud' for netatmo integration not ready yet: 500, message='Internal Server Error', url=URL('https://account-link.nabucasa.com/refresh_token/netatmo'); Retrying in background

Additional information

No response

balloob commented 2 years ago

So the 500 error here is a bug. It's actually receiving a 400 from Netatmo. So a bad request.

@cgtobi did we change the request?

homeassistant commented 2 years 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! (message by CodeOwnersMention)


netatmo documentation netatmo source (message by IssueLinks)

ludeeus commented 2 years ago

In pre 2022.10 we requested these scopes:

[
    "access_camera",
    "access_presence",
    "read_camera",
    "read_homecoach",
    "read_presence",
    "read_smokedetector",
    "read_station",
    "read_thermostat",
    "write_camera",
    "write_presence",
    "write_thermostat",
]

After 2022.10 these are requested:

[
    "access_camera",  # Netatmo camera products
    "access_doorbell",  # Netatmo Smart Video Doorbell
    "access_presence",  # Netatmo Smart Outdoor Camera
    "read_bubendorff",  # Bubbendorf shutters
    "read_camera",  # Netatmo camera products
    "read_carbonmonoxidedetector",  # Netatmo CO sensor
    "read_doorbell",  # Netatmo Smart Video Doorbell
    "read_homecoach",  # Netatmo Smart Indoor Air Quality Monitor
    "read_magellan",  # Legrand Wiring device or Electrical panel products
    "read_mx",  # BTicino Classe 300 EOS
    "read_presence",  # Netatmo Smart Outdoor Camera
    "read_smarther",  # Smarther with Netatmo thermostat
    "read_smokedetector",  # Smart Smoke Alarm information and events
    "read_station",  # Netatmo weather station
    "read_thermostat",  # Netatmo climate products
    "write_bubendorff",  # Bubbendorf shutters
    "write_camera",  # Netatmo camera products
    "write_magellan",  # Legrand Wiring device or Electrical panel products
    "write_mx",  # BTicino Classe 300 EOS
    "write_presence",  # Netatmo Smart Outdoor Camera
    "write_smarther",  # Smarther products
    "write_thermostat",  # Netatmo climate products
]
cgtobi commented 2 years ago

Right, the scope changed. This shouldn't be an issue with individual dev accounts which I'd recommend anyway to make use of webhook events. We might have to update the scope access for the HA Cloud Link. I'll drop I dropped them an email.

FrancWest commented 2 years ago

After installing 2022.10.0b0 or 2022.10.0b1 the Netatmo integration required me to re-authenticate. However, I'm unable to do so. After logging on to the Netatmo website nothing happens when I click on 'Yes, I accept'. The page just refreshes and on Home Assistant there's no refresh taking place. Integration still states 'reconfigure'. Deleting the integration and re-adding it doesn't work either. It won't accept the authorization.

cgtobi commented 2 years ago

@FrancWest this is an issue related to Home Assistant Cloud. We try to resolve this ASAP. Depending on your devices I might advise you to use a Netatmo dev account to utilize webhook events.

ludeeus commented 2 years ago

After some investigation regarding the scopes, it seems that when access_doorbell and read_doorbell are in the requested scopes it fails and authentication is not possible, by omitting these 2 everything works as expected (at least for me as I do not have any doorbells 😄) Why Netatmo treats this way and any other app differently, only Netatmo can answer.

cgtobi commented 2 years ago

Thanks for investigating @ludeeus. I'll submit a fix that excludes those when using HA cloud until we receive notice from Netatmo.