PiotrMachowski / Home-Assistant-custom-components-Hydro-IMGW

This custom integration retrieves data from hydro stations from hydro.imgw.pl.
MIT License
14 stars 6 forks source link

hydro_imgw: Error on device update! #3

Closed balkonrad closed 3 years ago

balkonrad commented 3 years ago

Hi Piotr, I need to raise the issue which comes after HA update(2021.9.0). Error log as follows:

First occurred: 13:07:15 (1 occurrences)
Last logged: 13:07:15

hydro_imgw: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 353, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f71b25a50a0>: Failed to establish a new connection: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='hydro.imgw.pl', port=443): Max retries exceeded with url: /api/station/hydro/?id=152210170 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f71b25a50a0>: Failed to establish a new connection: [Errno 110] Operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 633, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/hydro_imgw/sensor.py", line 84, in update
    request = requests.get(address, headers=headers)
  File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='hydro.imgw.pl', port=443): Max retries exceeded with url: /api/station/hydro/?id=152210170 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f71b25a50a0>: Failed to establish a new connection: [Errno 110] Operation timed out'))
balkonrad commented 3 years ago

@PiotrMachowski

PiotrMachowski commented 3 years ago

It's possible that this error was caused by a temporary network problem. Does the sensor update the data now?

balkonrad commented 3 years ago

Unfortunetly no, let's give it couple of hours and I will return to you ok?

PiotrMachowski commented 3 years ago

Hmmm, I have checked my setup and I also have this error (on 2021.8)... It's possible that they have added some traffic filtering mechanisms, I will have to create a workaround if it is the case.

balkonrad commented 3 years ago

But until literally no more than an hour, an issue occur, so something has changed there since then.

PiotrMachowski commented 3 years ago

The last successful update in my HA was ~6h ago

balkonrad commented 3 years ago

The problem seems to be solved

image

PiotrMachowski commented 3 years ago

Great!