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
72.55k stars 30.35k forks source link

Netatmo public sensor fails randomly on boot #17926

Closed bigboban closed 4 years ago

bigboban commented 5 years ago

Home Assistant release with the issue: 0.81.0

Last working Home Assistant release (if known): N/A

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

Component/platform:

Description of problem: Netatmo public sensors fails on boot randomly. Alomst every boot some of netatmo public sensors is unavailable (see pic). On next boot sometimes ok, sometimes other netatmo public sensor is gone.

Netatmo public sensor availability stays same (ok, not-ok) until next boot. So i have to reboot HA several times until all netatmo public sensors are ok.

image

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

- platform: netatmo_public
  areas:
    - lat_ne: 50.0263758
      lon_ne: 14.4603819
      lat_sw: 49.9843125
      lon_sw: 14.3588872
      monitored_conditions:
        - temperature
        - pressure
        - humidity
        - rain
        - windstrength
        - guststrength

Traceback (if applicable):

Additional information:

Danielhiversen commented 5 years ago

Could you check the log?

bigboban commented 5 years ago

Many restarts and problem is probably gone. Maybe fixed in some last version..?

bigboban commented 5 years ago

Problem is back. Only one of netatmo-public sensor (public-data-pressure) fails on boot. Log is here:

2018-11-06 20:13:25 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.netatmo_public

...

2018-11-06 20:13:35 WARNING (MainThread) [homeassistant.components.sensor] Setup of platform netatmo_public is taking over 10 seconds.
2018-11-06 20:13:36 ERROR (MainThread) [homeassistant.components.sensor] netatmo_public: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 251, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/netatmo_public.py", line 124, in update
    self.netatmo_data.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/netatmo_public.py", line 179, in update
    filtering=True)
  File "/usr/local/lib/python3.6/site-packages/smart_home/PublicData.py", line 52, in __init__
    resp = postRequest(_GETPUBLIC_DATA, post_params)
  File "/usr/local/lib/python3.6/site-packages/smart_home/__init__.py", line 28, in postRequest
    resp = urllib.request.urlopen(req, params, timeout=timeout) if params else urllib.request.urlopen(req, timeout=timeout)
  File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1321, in do_open
    r = h.getresponse()
  File "/usr/local/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/local/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.6/ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/local/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
2018-11-06 20:13:37 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.netatmo_public_data_humidity, old_state=None, new_state=<state sensor.netatmo_public_data_humidity=84.7; unit_of_measurement=%, friendly_name=Netatmo Public Data Humidity, icon=mdi:water-percent, device_class=humidity @ 2018-11-06T20:13:37.644488+01:00>>
2018-11-06 20:13:37 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.netatmo_public_data_wind_strength, old_state=None, new_state=<state sensor.netatmo_public_data_wind_strength=1.4; unit_of_measurement=km/h, friendly_name=Netatmo Public Data Wind Strength, icon=mdi:weather-windy @ 2018-11-06T20:13:37.651493+01:00>>
2018-11-06 20:13:37 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.netatmo_public_data_rain, old_state=None, new_state=<state sensor.netatmo_public_data_rain=0.0; unit_of_measurement=mm, friendly_name=Netatmo Public Data Rain, icon=mdi:weather-rainy @ 2018-11-06T20:13:37.658660+01:00>>
2018-11-06 20:13:37 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.netatmo_public_data_gust_strength, old_state=None, new_state=<state sensor.netatmo_public_data_gust_strength=3.2; unit_of_measurement=km/h, friendly_name=Netatmo Public Data Gust Strength, icon=mdi:weather-windy @ 2018-11-06T20:13:37.665858+01:00>>
2018-11-06 20:13:37 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.netatmo_public_data_temperature, old_state=None, new_state=<state sensor.netatmo_public_data_temperature=11.3; unit_of_measurement=°C, friendly_name=Netatmo Public Data Temperature, icon=mdi:thermometer, device_class=temperature @ 2018-11-06T20:13:37.677141+01:00>>
2018-11-06 20:13:37 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 14.2 seconds.
Bry50 commented 5 years ago

i have same problem

Here is log file

2018-12-13 14:02:26 WARNING (MainThread) [homeassistant.components.sensor] Setup of platform netatmo_public is taking over 10 seconds.
2018-12-13 14:02:26 ERROR (MainThread) [homeassistant.components.sensor] netatmo_public: Error on device update!
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/data/data/com.termux/files/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/homeassistant/components/sensor/netatmo_public.py", line 124, in update
    self.netatmo_data.update()
  File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.7/site-packages/homeassistant/components/sensor/netatmo_public.py", line 179, in update
    filtering=True)
  File "/data/data/com.termux/files/home/.homeassistant/deps/lib/python3.7/site-packages/smart_home/PublicData.py", line 52, in __init__
    resp = postRequest(_GETPUBLIC_DATA, post_params)
  File "/data/data/com.termux/files/home/.homeassistant/deps/lib/python3.7/site-packages/smart_home/__init__.py", line 28, in postRequest
    resp = urllib.request.urlopen(req, params, timeout=timeout) if params else urllib.request.urlopen(req, timeout=timeout)
  File "/data/data/com.termux/files/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/data/data/com.termux/files/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/data/data/com.termux/files/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/data/data/com.termux/files/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/data/data/com.termux/files/usr/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/data/data/com.termux/files/usr/lib/python3.7/urllib/request.py", line 1320, in do_open
    r = h.getresponse()
  File "/data/data/com.termux/files/usr/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/data/data/com.termux/files/usr/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/data/data/com.termux/files/usr/lib/python3.7/http/client.py", line 257, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/data/data/com.termux/files/usr/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/data/data/com.termux/files/usr/lib/python3.7/ssl.py", line 1052, in recv_into
    return self.read(nbytes, buffer)
  File "/data/data/com.termux/files/usr/lib/python3.7/ssl.py", line 911, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
bigboban commented 5 years ago

Some observation - all netatmo sensors has same behavior - if it is not available in time of the boot of HA sensor is not created at all instead of "unavailable" state. So if some input is not accessible in time of boot (netatmo public, netatmo outdoor sensor, ..) sensor is not created until next boot.

I think this is bad implementation of netatmo at all and should be fixed.

balloobbot commented 5 years ago

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 :+1:

dshokouhi commented 5 years ago

Is this still an issue you are experiencing? Can you please try upgrading to the latest version of Home Assistant (0.90) and report back if this is still a problem? Thanks!

terveer commented 5 years ago

Still happens to me.

2019-03-22 17:57:14 ERROR (MainThread) [homeassistant.components.sensor] netatmo_public: Error on device update!
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 379, 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/sensor/netatmo_public.py", line 124, in update
    self.netatmo_data.update()
  File "/usr/src/app/homeassistant/util/__init__.py", line 224, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/app/homeassistant/components/sensor/netatmo_public.py", line 179, in update
    filtering=True)
  File "/usr/local/lib/python3.7/site-packages/smart_home/PublicData.py", line 54, in __init__
    self.raw_data = resp["body"]
TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/smart_home/__init__.py", line 35, 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 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  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 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
Maurotb commented 5 years ago

Hi, same problem here, after updating from 0.89.1 to 0.92.2 two times after reboot i see my netatmo energy and thermostat, now i rebbot,reboot but i have only this error

2019-05-07 21:42:17 ERROR (SyncWorker_10) [smart_home] Traceback (most recent call last):
  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 531, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  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 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400:

2019-05-07 21:42:17 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: switch 93F52C_RL_1, sending update
2019-05-07 21:42:17 ERROR (MainThread) [homeassistant.setup] Error during setup of component netatmo
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 156, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  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/site-packages/homeassistant/components/netatmo/__init__.py", line 91, in setup
    'read_station read_camera access_camera '
  File "/usr/local/lib/python3.7/site-packages/pyatmo.py", line 85, in __init__
    self._accessToken = resp["access_token"]
TypeError: 'NoneType' object is not subscriptable
2019-05-07 21:42:17 INFO (SyncWorker_12) [homeassistant.loader] Loaded configurator from homeassistant.components.configurator
ievans commented 5 years ago

@bigboban, I have the exact same issue as you on HA version 0.93.0. It works fine after a reboot, but a few hours later it fails with this error (ssl read) and does not try again:

ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.netatmo_indoor_humidity fails
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/home/pi/.local/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/homeassistant/components/netatmo/sensor.py", line 216, in update                                                                   self.netatmo_data.update()
  File "/home/pi/.local/lib/python3.5/site-packages/homeassistant/components/netatmo/sensor.py", line 544, in update
    self.station_data = self._detect_platform_type()
  File "/home/pi/.local/lib/python3.5/site-packages/homeassistant/components/netatmo/sensor.py", line 522, in _detect_platform_type
    station_data = self.data_class(self.auth)
  File "/home/pi/.homeassistant/deps/lib/python3.5/site-packages/smart_home/WeatherStation.py", line 23, in __init__
    resp = postRequest(self.urlReq, postParams)
  File "/home/pi/.homeassistant/deps/lib/python3.5/site-packages/smart_home/__init__.py", line 39, in postRequest
    if params
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.5/urllib/request.py", line 1257, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1198, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.5/socket.py", line 576, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.5/ssl.py", line 937, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.5/ssl.py", line 799, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.5/ssl.py", line 583, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
teocannata commented 5 years ago

Same issue from the first version to the current version (0.96.4) This timeout happens at platform setup, I agree that's a bad platform implementation. I have two netatmo cameras and the probability to have both available after HA restart is very low and I usually have to reboot dozen times. Very very annoying.

stale[bot] commented 4 years ago

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.

teocannata commented 4 years ago

Version 0.100.2 and problem still there.

stale[bot] commented 4 years ago

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.