core: Netatmo weatherstation broken in 0.93.1

Home Assistant release with the issue:

Last working Home Assistant release (if known): I believe it was 0.92 something

Operating environment (Hass.io/Docker/Windows/etc.): Docker

Component/platform: https://www.home-assistant.io/components/netatmo/

Description of problem: Netatmo weatherstation has always worked fine. After updating to 0.93.1 the sensors work for 10ish minutes before crashing. After that, the sensors does not update any longer. It seems from the traceback in the logfile that something crashes in the update.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

netatmo:
  api_key: !secret netatmo_api_key
  secret_key: !secret netatmo_secret_key
  username: !secret netatmo_email
  password: !secret netatmo_password

Traceback (if applicable):

2019-05-19 23:23:02 ERROR (SyncWorker_8) [homeassistant.components.netatmo.sensor] No Weather or HomeCoach devices found for None
2019-05-19 23:30:26 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.netatmo_kjellerstua_humidity is taking over 10 seconds
2019-05-19 23:30:26 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_kjellerstua_humidity fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 377, 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/app/homeassistant/components/netatmo/sensor.py", line 216, in update
    self.netatmo_data.update()
  File "/usr/src/app/homeassistant/components/netatmo/sensor.py", line 544, in update
    self.station_data = self._detect_platform_type()
  File "/usr/src/app/homeassistant/components/netatmo/sensor.py", line 522, in _detect_platform_type
    station_data = self.data_class(self.auth)
  File "/usr/local/lib/python3.7/site-packages/smart_home/WeatherStation.py", line 23, in __init__
    resp = postRequest(self.urlReq, postParams)
  File "/usr/local/lib/python3.7/site-packages/smart_home/__init__.py", line 39, in postRequest
    if params
  File "/usr/local/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/local/lib/python3.7/urllib/request.py", line 1320, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/local/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.7/http/client.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/ssl.py", line 1052, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.7/ssl.py", line 911, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

Additional information:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 19
  • Comments: 111 (23 by maintainers)

Most upvoted comments

I’m still having the issue with 0.94.0b3.

I’m pretty sure the next beta will ship with #24190 along with a new release of pyatmo. We are still looking into the multiple errors. This issue was automatically closed by PR #24088. I’ll reopen since it still is an issue.

I think there are some network problem with netatmo api. So, maybe the final solution is a better handling of these errors in home assistant, preventing the crashing of sensor update. Just because there is some python script that suddenly stop itself after this error, and it is confirmed by the fact that restarting the home assistant all sensors data become available again

Il ven 7 giu 2019, 10:55 Curtis Kennington notifications@github.com ha scritto:

@bend https://github.com/bend The last sensor data was 06:51. This error occurred at 07:01.

I have seen that there is an ongoing PR with Netatmo stability being the focus #24190 https://github.com/home-assistant/home-assistant/pull/24190

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/24002?email_source=notifications&email_token=AKUOK4HXNNV7HLW3JJWNLR3PZIPBXA5CNFSM4HN6VLRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXFH52A#issuecomment-499810024, or mute the thread https://github.com/notifications/unsubscribe-auth/AKUOK4CT3KMJHAHLQF2B2VTPZIPBXANCNFSM4HN6VLRA .

Hi everyone, I think this issue is related to the http service unavailable error. The WeatherStation.py crashes because it calls the /smart_home/init.py, and if the netatmo server are not available, the init.py return an object None without crashing (because it is managed by a “try - except” routine). BUT, the WeatherStation.py crashes on line line 24, because the object None is not allowed. So I’m trying this change to prevent WeatherStation.py to crash:

        resp = postRequest(self.urlReq, postParams)
        if resp==None:
            print("Service temporary unavailable")
            return 
        self.rawData = resp["body"]["devices"]

I will let you know if it will solve this issue.

Almost 24 hours without problems with netatmo data update. So I can confirm, the problem was the “None” object

Same issue here. A reboot of HASS solves the problem for a few hours, and than data are not gathered anymore. Was working fine with 0.92.X, and buggy since the update to 0.93.X

Here is what I get in the log file on my side:

2019-05-19 20:25:04 INFO (SyncWorker_4) [homeassistant.components.netatmo.sensor] Netatmo refresh interval reset to 300 seconds
2019-05-19 20:30:21 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.netatmo_chambre_humidity is taking over 10 seconds
2019-05-19 20:30:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_chambre_humidity fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 377, 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/app/homeassistant/components/netatmo/sensor.py", line 216, in update
    self.netatmo_data.update()
  File "/usr/src/app/homeassistant/components/netatmo/sensor.py", line 544, in update
    self.station_data = self._detect_platform_type()
  File "/usr/src/app/homeassistant/components/netatmo/sensor.py", line 522, in _detect_platform_type
    station_data = self.data_class(self.auth)
  File "/usr/local/lib/python3.7/site-packages/smart_home/WeatherStation.py", line 23, in __init__
    resp = postRequest(self.urlReq, postParams)
  File "/usr/local/lib/python3.7/site-packages/smart_home/__init__.py", line 39, in postRequest
    if params
  File "/usr/local/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/local/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/local/lib/python3.7/urllib/request.py", line 1320, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/local/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.7/http/client.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/ssl.py", line 1052, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.7/ssl.py", line 911, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

(FWIW, I’m using Docker too).

I can confirm the bug is fixed with the new library and new …sensor.py. Thank you

With the latest #24190 i can say it’s looks like fixed ! Now i have 48 hours of history without any “flat line” ! Great job @Danielhiversen & @cgtobi 👍 netatmo_fixed

I think the errors reported here should be fixed by https://github.com/home-assistant/home-assistant/pull/24190 and pyatmo 1.13

in addition , the error is ‘normal’ if the netatmo api not responding. But the sensor should not stop works .

init.py of smart_home is part of pyatmo…

@rosch100 @chiefcomm if you are impatient added this in components/netatmo/sensor.py

@@ -530,6 +530,12 @@
                             str(self.station)
                             )
             raise
+        except TypeError as e:
+            _LOGGER.warning("Type Error, type error: {}".format(e))
+            _LOGGER.error(traceback.format_exc())
+        except:
+            _LOGGER.warning("general exception")
+            _LOGGER.error(traceback.format_exc())

it is not very elegant but it is functional

@cgtobi, pyatmo is upgrated to 1.12 with homeassistant 0.94.2

Stopped working on 0.94.0 after 36 hours. That’s a lot better than 0.93 that stopped working after 2-8 hours.

Hello, one thing that has been changed from working HA (0.91.4) are these lines:

MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5) MIN_TIME_BETWEEN_EVENT_UPDATES = timedelta(seconds=5)

They were:

MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10) MIN_TIME_BETWEEN_EVENT_UPDATES = timedelta(seconds=10)

Could it be that Netatmo servers ban requests that are being sent too often? I found some info from Netatmo API notes that back this up:

I know that this applies to Webhooks but maybe Netatmo has something similar concerning this issue:

“If you stopped receiving events abruptly while there are still events happening in the user’s Home it is probably because your webhook has been banned. After 5 failures in the course of one hour, webhooks get banned and Netatmo server will stop sending events for the next 24h”.

I just downgraded my HA to working setup. My automations etc. rely on Netatmo CO2 / Temperatures etc.

Hi everyone, I think this issue is related to the http service unavailable error. The WeatherStation.py crashes because it calls the /smart_home/init.py, and if the netatmo server are not available, the init.py return an object None without crashing (because it is managed by a “try - except” routine). BUT, the WeatherStation.py crashes on line line 24, because the object None is not allowed. So I’m trying this change to prevent WeatherStation.py to crash:

        resp = postRequest(self.urlReq, postParams)
        if resp==None:
            print("Service temporary unavailable")
            return 
        self.rawData = resp["body"]["devices"]

I will let you know if it will solve this issue.

The issue is auto closed when the pull request is merged. You will see the fix the release note

Just a quick question regarding the update process: are issues always closed even though the fix hasn’t been released yet? I finally downgraded to get my weather station running again, but to let Home Assistant become more user friendly for non-techies, especially the process of fixing integrations could be a bit more transparent in my eyes.

i saw the same thing … see my previous post to correct

I also have issues with my Netatmo weather station, but I see this in the log:

Module name: "Wind" not found
10:17 PM components/netatmo/sensor.py (ERROR)
Module name: "Rain" not found
10:17 PM components/netatmo/sensor.py (ERROR)
Module name: "Indoor" not found
10:17 PM components/netatmo/sensor.py (ERROR)
Module name: "Outdoor" not found
10:17 PM components/netatmo/sensor.py (ERROR)
No Weather or HomeCoach devices found for Renvyle
10:17 PM components/netatmo/sensor.py (ERROR)

I wonder have Netatmo changed something

EDIT:

I am also linked to Meteoware Plus. They pushed a bug fix for something that netatmo changed

What is interesting the errors seem to be related to humidity sensors only, but later affect the whole stations.