Core: Netatmo timeout errors during token update

Created on 17 Apr 2020  ·  45Comments  ·  Source: home-assistant/core

The problem


Before I used configuration.yaml to add my netatmo stations. And everything was ok.
Now I used the netatmo integration but in the log I recived a lot of "error".

Environment


Home Assistant 0.108.5
Path to configuration.yaml: /home/homeassistant/.homeassistant

Developed by a bunch of awesome people.

Published under the Apache 2.0 license
Source: server — frontend-ui

Built using Python 3, Polymer, Icons by Google and MaterialDesignIcons.com.

Frontend version: 20200407.2 - latest

  • Home Assistant Core release with the issue: not sure when started. But the problem is for sure in 0.107.7 and later
  • Last working Home Assistant Core release (if known):
  • Operating environment (Home Assistant/Supervised/Docker/venv): I use a raspberry pi 4 in virtual env becouse I use raspberry also for other stuff.
  • Integration causing this issue: netatmo
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml


I use UI on frontend so my configuration.yaml not report netatmo things


Traceback/Error logs

2020-04-11 13:48:39 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_netatmo_indoor_temperature fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/pyatmo/auth.py", line 129, in query
    rsp = self._oauth.post(url=url, data=params, timeout=timeout)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
    url, http_method=method, body=data, headers=headers
  File "/srv/homeassistant/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/netatmo/sensor.py", line 225, in update
    self.netatmo_data.update()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/netatmo/sensor.py", line 550, in update
    self.station_data = self.station_data.__class__(self.auth)
  File "/srv/homeassistant/lib/python3.7/site-packages/pyatmo/weather_station.py", line 24, in __init__
    resp = self.authData.post_request(url=self.urlReq)
  File "/srv/homeassistant/lib/python3.7/site-packages/pyatmo/auth.py", line 143, in post_request
    resp = query(url, params, timeout, 3)
  File "/srv/homeassistant/lib/python3.7/site-packages/pyatmo/auth.py", line 137, in query
    self._oauth.token = self.refresh_tokens()
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/netatmo/api.py", line 32, in refresh_tokens
    self.session.async_ensure_token_valid(), self.hass.loop
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 413, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 78, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/cloud/account_link.py", line 143, in _async_refresh_token
    self.hass.data[DOMAIN], self.service, token["refresh_token"]
  File "/srv/homeassistant/lib/python3.7/site-packages/hass_nabucasa/account_link.py", line 112, in async_fetch_access_token
    resp.raise_for_status()
  File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 504, message='Gateway Time-out', url='https://account-link.nabucasa.com/refresh_token/netatmo
2020-04-11 13:49:40 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_netatmo_indoor_co2 fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/pyatmo/auth.py", line 129, in query
    rsp = self._oauth.post(url=url, data=params, timeout=timeout)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
    url, http_method=method, body=data, headers=headers
  File "/srv/homeassistant/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

Additional information

I have only 2 stations (one internal and one external).
The data in home assistant are ok. I can use the sensor and everything is ok. (I suppose)
The first error that appears on the log file is:
[homeassistant.components.netatmo] Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 443 and 80. (21) when accessing 'https://api.netatmo.com/api/addwebhook'

But I can't forward the ports 443 an 80 on my router because I already use them for other services on my raspberry (that is the same where is installed homeassistant.)

netatmo stale

Most helpful comment

Got it to work again. Upgraded to 0.108.8 from 0.108.6 and the setup worked flawlessly from the UI. Entities got new names though.

All 45 comments

Hey there @cgtobi, mind taking a look at this issue as its been labeled with a integration (netatmo) you are listed as a codeowner for? Thanks!

I'm seeing the same errors, but mine doesn't seem to continue. I just restarted and am not able to get past this:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/netatmo/camera.py", line 65, in async_setup_entry
    async_add_entities(await hass.async_add_executor_job(get_entities), True)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/camera.py", line 53, in get_entities
    for camera in camera_data.get_all_cameras():
  File "/usr/src/homeassistant/homeassistant/components/netatmo/camera.py", line 237, in get_all_cameras
    self.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/camera.py", line 261, in update
    self.camera_data = pyatmo.CameraData(self.auth, size=100)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/camera.py", line 30, in __init__
    resp = self.authData.post_request(url=_GETHOMEDATA_REQ, params=postParams)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 143, in post_request
    resp = query(url, params, timeout, 3)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 137, in query
    self._oauth.token = self.refresh_tokens()
  File "/usr/src/homeassistant/homeassistant/components/netatmo/api.py", line 32, in refresh_tokens
    self.session.async_ensure_token_valid(), self.hass.loop
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 413, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 78, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/components/cloud/account_link.py", line 143, in _async_refresh_token
    self.hass.data[DOMAIN], self.service, token["refresh_token"]
  File "/usr/local/lib/python3.7/site-packages/hass_nabucasa/account_link.py", line 112, in async_fetch_access_token
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 504, message='Gateway Time-out', url='https://account-link.nabucasa.com/refresh_token/netatmo

It has been sitting there for an hour.

Got the same issue. Netatmon Weather Station only (no other netatmo components). It was added via standard integration. I do receive the data from the netatmo sensors, but the HA log keeps filing up with the following errors.
Running HA 0.108.3 on HassOS 3.12

2020-04-18 06:08:47 WARNING (MainThread) [homeassistant.components.sensor] Updating netatmo sensor took longer than the scheduled update interval 0:00:30
2020-04-18 06:08:55 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.netatmo_indoor_co2 is taking over 10 seconds
2020-04-18 06:09:18 WARNING (MainThread) [homeassistant.components.sensor] Updating netatmo sensor took longer than the scheduled update interval 0:00:30
2020-04-18 06:09:45 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_indoor_co2 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 129, in query
    rsp = self._oauth.post(url=url, data=params, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
    url, http_method=method, body=data, headers=headers
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/sensor.py", line 225, in update
    self.netatmo_data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/sensor.py", line 550, in update
    self.station_data = self.station_data.__class__(self.auth)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/weather_station.py", line 24, in __init__
    resp = self.authData.post_request(url=self.urlReq)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 143, in post_request
    resp = query(url, params, timeout, 3)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 137, in query
    self._oauth.token = self.refresh_tokens()
  File "/usr/src/homeassistant/homeassistant/components/netatmo/api.py", line 32, in refresh_tokens
    self.session.async_ensure_token_valid(), self.hass.loop
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 413, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 78, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/components/cloud/account_link.py", line 143, in _async_refresh_token
    self.hass.data[DOMAIN], self.service, token["refresh_token"]
  File "/usr/local/lib/python3.7/site-packages/hass_nabucasa/account_link.py", line 112, in async_fetch_access_token
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 504, message='Gateway Time-out', url='https://account-link.nabucasa.com/refresh_token/netatmo

Could you please try to manually configure client ID/secret and check if this still happens?

Could you please try to manually configure client ID/secret and check if this still happens?

You mean deleting the standard netatmo integration and reverting back to configuration.yaml ?
As I don't see where to specify the client ID/secret from the integration screen.

Since some days we see a lot timeouts on api.netatmo.com. They is hosted on Azure, maybe they have an issue. We need ask here support.

Could you please try to manually configure client ID/secret and check if this still happens?

Sorry but I don't know what you want I do... I have to delete the integration and add on my configuration.yaml this instructions?

netatmo:
  client_id: YOUR_CLIENT_ID
  client_secret: YOUR_CLIENT_SECRET

(That I used before I moved to integration?)

@Metus88 Yeah, exactly that.

I did. I delated the integration and I added on my configuration.yaml:

netatmo:
  client_id: YOUR_CLIENT_ID
  client_secret: YOUR_CLIENT_SECRET

When I restarted home assistant no new sensors were detected and all my old Netatmo sensors were not working.

I remember that there was a different name method between automatic integration sensors (exemple: sensor.netatmo_netatmo_indoor_temperature) and manual integrated using configuration.yaml (exemple: sensor.netatmo_indoor_temperature)... there is a "netatmo_" add. However this time I don't know why no sensors are detected in the old way... No error appears on the log but no sensors are detected by home assistant... so it's useless.

So I added new integration Netatmo and a popup asks me if take access information from configuration.yaml and I said yes. I restarted home assistant and all sensors work again now.
In the log file same error:

2020-04-19 15:11:24 ERROR (MainThread) [homeassistant.components.netatmo] Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 443 and 80. (21) when accessing 'https://api.netatmo.com/api/addwebhook'

Now I wait if it's only this (1 error is ok, no big problem) or they will appear later more and more.

However, do you know why the old way doesn't detect anymore the sensors? (I did not remember very well how I added the Netatmo sensors the first time... months ago)

I have deleted the error:
ERROR (MainThread) [homeassistant.components.netatmo] Error during webhook registration - 400 - Bad request - Allowed ports for webhooks are 443 and 80. (21) when accessing 'https://api.netatmo.com/api/addwebhook'
when I added in my configuration.yaml this
http:
base_url: https://mydomain
With this I don´t see that error anymore

@Metus88 What I think you refer to by "the old way" is the configuration of the individual platforms where you'd specify the sensors and devices manually? This has been deprecated a long time ago. If you meant something else then please let me know. The way the Netatmo integration works now (for quite a while) is by auto discovery only. The one error left is irrelevant if you only have a weather station. See comment below.

@myerdacom I don't understand what exactly you mean by that. How to setup is described here but is not relevant if you only have a weather station.

The last days my dockerized HA "crashes" daily, logs suggest its running but the webinterface, Android app, automations, etc. aren't running of responding. Through Telegram I get a lot of stuff pushed through a bot and this night that stopped on 05:37. So I got through my 380.000.000 lines(yes that many debug level lines) logs. And around 05:50 i see this netatmo error:

2020-04-20 05:50:26 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_xyz_temperature fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 129, in query
    rsp = self._oauth.post(url=url, data=params, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
    url, http_method=method, body=data, headers=headers
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/sensor.py", line 225, in update
    self.netatmo_data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/sensor.py", line 550, in update
    self.station_data = self.station_data.__class__(self.auth)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/weather_station.py", line 24, in __init__
    resp = self.authData.post_request(url=self.urlReq)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 143, in post_request
    resp = query(url, params, timeout, 3)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 137, in query
    self._oauth.token = self.refresh_tokens()
  File "/usr/src/homeassistant/homeassistant/components/netatmo/api.py", line 32, in refresh_tokens
    self.session.async_ensure_token_valid(), self.hass.loop
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 413, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 78, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/components/cloud/account_link.py", line 143, in _async_refresh_token
    self.hass.data[DOMAIN], self.service, token["refresh_token"]
  File "/usr/local/lib/python3.7/site-packages/hass_nabucasa/account_link.py", line 112, in async_fetch_access_token
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 504, message='Gateway Time-out', url='https://account-link.nabucasa.com/refresh_token/netatmo
2020-04-20 05:50:26 DEBUG (SyncWorker_13) [requests_oauthlib.oauth2_session] Invoking 0 protected resource request hooks.
2020-04-20 05:50:26 DEBUG (SyncWorker_13) [requests_oauthlib.oauth2_session] Adding token {'scope': ['read_camera', 'read_homecoach', 'read_presence', 'read_smokedetec$
2020-04-20 05:50:26 DEBUG (MainThread) [hass_nabucasa.account_link] Fetching tokens for netatmo

These are, except some "standard" "ERROR" logs (1 failing automation during the night and my WLED device going down at night) the only errors in my log after 05:37. So my gut feeling is saying that this NetAtmo failing is crashing my HA instance. This also because I didn't change that much on my yaml files, only update the last days from 0.108.5 to 0.108.6 about 3 days ago.

Mayby the.5 or .6 update in combination Nubu Case-ed NetAtmo it is!?

Will now switch back to the yaml NetAtmo version.

We'll investigate this. My impression is that, like @pvizeli wrote earlier, the (European) cloud experiences a much higher usage than before Corona, which might cause timeouts.

The timeout comes from api.netatmo.com. We just forward your token renew requests because the token is all local on your machine. I am was going over the error logs, so it looks like the issue is mostly around 23:00 - 08:00, and NetAtmo Cloud is hosted in NL.

You can use the YAML version and it will work during the day, but I think it ends up in same issue on the night or next night (it is not every night). Let's hope they fix the issue soon.

I needed to re-add the integration but it just hangs on the nabu casa site with "Please wait, we are linking your account...". Can't see any errors in the log.

This account-link.nabucasa.com page can’t be found HTTP ERROR 404

@lordfiSh a little bit more context would be appreciated. ;-)

Sorry, my Netamo stop working for a few weeks now. Same Error as in https://github.com/home-assistant/core/issues/34345#issuecomment-615530778

Logger: homeassistant.core
Source: components/cloud/account_link.py:143
First occurred: 10:02:12 AM (4 occurrences)
Last logged: 10:03:20 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 129, in query
    rsp = self._oauth.post(url=url, data=params, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 578, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
    url, http_method=method, body=data, headers=headers
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/netatmo/climate.py", line 136, in async_setup_entry
    async_add_entities(await hass.async_add_executor_job(get_entities), True)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/netatmo/climate.py", line 119, in get_entities
    home_data.setup()
  File "/usr/src/homeassistant/homeassistant/components/netatmo/climate.py", line 427, in setup
    self.homedata = pyatmo.HomeData(self.auth)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/thermostat.py", line 26, in __init__
    resp = self.authData.post_request(url=_GETHOMESDATA_REQ)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 143, in post_request
    resp = query(url, params, timeout, 3)
  File "/usr/local/lib/python3.7/site-packages/pyatmo/auth.py", line 137, in query
    self._oauth.token = self.refresh_tokens()
  File "/usr/src/homeassistant/homeassistant/components/netatmo/api.py", line 32, in refresh_tokens
    self.session.async_ensure_token_valid(), self.hass.loop
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 413, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 78, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/components/cloud/account_link.py", line 143, in _async_refresh_token
    self.hass.data[DOMAIN], self.service, token["refresh_token"]
  File "/usr/local/lib/python3.7/site-packages/hass_nabucasa/account_link.py", line 112, in async_fetch_access_token
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 504, message='Gateway Time-out', url='https://account-link.nabucasa.com/refresh_token/netatmo
Connection lost. Reconnecting…

If you open https://account-link.nabucasa.com/refresh_token/netatmo you get the 404

hi everyone, my first time on this forum,
when a try ton integrate my Netatmo camera, adding token and id to yaml.conf and opening the browser from the link in integration. New webpage open, I accept to link Hassio and Netatmo but web page doesn't open and an error, on safari and chrome

could you help me ?

To use the key/secret in configuration.yaml you have to choose configuration.yaml instead of HA Cloud when adding the integration. Please remove the integration, restart HA and try again.

I put :

Example configuration.yaml entry

netatmo:
client_id: "Xxxxxxxxxxxxxxx"
client_secret: "xxxxxxxxxxxx"
in configuration.yaml

after that I go to configuration in the section discover : Netatmo click to configure and it go directly to an new website auth.netatmo.com .... next I click to accept and after that I have no result

I don't have to choose configuration.yaml...
thanks to your answer

Please remove the integration, restart HA and try again. Make sure you're selecting configuration.yaml instead of HA Cloud.

Capture d’écran 2020-04-23 à 10 56 11
How do i avec Remove the integration ?

Ok, looks like it is not actually added. In this case just restart HA and make sure you're selecting configuration.yaml instead of HA Cloud when adding the integration.

Capture d’écran 2020-04-24 à 00 08 29

hi restart HA, also the R pi and I select configuration.yaml but nothing happen, keep frozen il the page above..

I also made new token but it change nothing...

I'll try to reproduce this tomorrow.

@nicolas1403 is you instance exposed to the WAN?

I'm also having problem with the integration. At first I deleted it and tried to add it again and it hangs at the nabu casa page and it is just spinning around and nothing happens. Can also confirm that around the 20th it stopped working.

Got it to work again. Upgraded to 0.108.8 from 0.108.6 and the setup worked flawlessly from the UI. Entities got new names though.

Can also confirm now upgrading to 0.108.8 made it work again

I made the release, restated hass, refresh and copy new token but don't work for me :/
do I have to put double quotes ? (I tried with and without) both don't work...

netatmo:
client_id: "XXX"
client_secret: "XXX"
thanks everyone for responding ;)

@nicolas1403 please see my question above

@nicolas1403 please see my question above

Hi, Yes I've seen , but I'm new and I don't know what it is ? (the Wan)?

Ok, sorry. The internet. WAN stands for wide area network.

But you might just try the HA cloud linking again.

ok thanks it's works with HA....
don't understand Ahah ^^
thanks for helping

My Netatmo integration also stopped working, now on 109.2

I removed the integration, readded it, and it's just spinning on the https://account-link.nabucasa.com/authorize_callback page (the api.netatmo page redirects here after authorization)

@eisams the Netatmo backend still might be flaky, please try again.

@cgtobi you are correct, now it worked!

Hi, I understand that the issue is related to Netatmo server load. I see it from time to time for the last months. Is there any other way to refresh the token than restarting Home Assistant and hoping for the best? If not; maybe a way to do it could be described? Could I for example use Postman and get a token and paste it somewhere? Or at least use Postman to verify that the Netatmo service is currently up so there is a fair chance for sucess if I reboot HA? It is a drag to restart Home Assistant 2-5 times just to get a refresh token which may or may not work...

Thanks for all your time spent on supporting this. I know how awfull it fells to support something that is not your fault!

I can't promise a quick remedy for this but I have forcing a token refresh on my list and a rough workaround implemented in DEV.

Hi again; I have another idea/question for a possible improvment also. I am in process of doing a lot of tweaks to HA and therefore need to restart often. It seems that the token gets renewed/fetched at every start of HA so after two or three concecutive restarts I get the token error. Maybe it could be possible to store the token so that it survives a restart of HA? I have very litle knowledge of the inner workings of HA and your Netatmo code so maybe this is a stupid suggestion.

Here it stopped for the second time in 6/7 days and the 4/5 time in 3/4 weeks. This is really getting ......
What is the best thing to do now? Back to the API keys? Nabucasa linked is no options right now...

Same here. Deleting it and recreating it fixes it for the length of the token.

Yes, please go back to using the individual API keys until this is sorted. Sorry about the inconvenience.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sibbl picture sibbl  ·  3Comments

bdraco picture bdraco  ·  3Comments

piitaya picture piitaya  ·  3Comments

sogeniusio picture sogeniusio  ·  3Comments

arangates picture arangates  ·  3Comments