Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities unavailable every night (connection refused) #20

Open
arnebret opened this issue Nov 1, 2023 · 12 comments · Fixed by #25
Open

Entities unavailable every night (connection refused) #20

arnebret opened this issue Nov 1, 2023 · 12 comments · Fixed by #25

Comments

@arnebret
Copy link

arnebret commented Nov 1, 2023

I can see all entities of this integration go to status 'Unavailable' for a few minutes every night. It's always around 04:00, so curious to find out if this is something others are seeing this as well.

The logs show a few things, but the most important seems to be:

2023-11-01 03:48:14.940 ERROR (SyncWorker_1) [custom_components.alpha_innotec.gateway_api] Unable to fetch data from API: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/dbmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f60847ed0>: Failed to establish a new connection: [Errno 111] Connection refused'))

The full logs with all relevant lines is below, but it seems the integration cannot connect with the Gateway. As far as I can see the Gateway is available at that time. The Gateway also runs the latest firmware available (2.2.39533).

So not sure why the Gateway would refuse the connection every night at around 4 AM.

Full logs below:

2023-11-01 03:16:12.426 ERROR (SyncWorker_5) [custom_components.alpha_innotec.controller_api] Unable to fetch data from API: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1378, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1378, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/alpha_innotec/controller_api.py", line 45, in call
    response = requests.post("http://{hostname}/{endpoint}".format(hostname=self.api_host, endpoint=endpoint),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2023-11-01 03:16:12.453 ERROR (MainThread) [custom_components.alpha_innotec.sensor] Unexpected error fetching Alpha Sensor data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/sensor.py", line 71, in _async_update_data
    return await self.get_thermostats(self.hass, self.gateway_api, self.controller_api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 64, in get_thermostats
    raise exception
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 26, in get_thermostats
    room_list: dict = await hass.async_add_executor_job(controller_api.room_list)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 97, in room_list
    return self.call("api/room/list")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 59, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2023-11-01 03:16:17.513 ERROR (MainThread) [custom_components.alpha_innotec.climate] Unexpected error fetching Alpha Sensor data: Failed to get data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/climate.py", line 73, in _async_update_data
    return await self.get_thermostats(self.hass, self.gateway_api, self.controller_api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 64, in get_thermostats
    raise exception
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 21, in get_thermostats
    rooms: dict = await hass.async_add_executor_job(gateway_api.all_modules)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 87, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 70, in call
    raise Exception('Failed to get data')
Exception: Failed to get data
2023-11-01 03:16:45.148 ERROR (SyncWorker_2) [custom_components.alpha_innotec.controller_api] Unable to fetch data from API: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1378, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1378, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/alpha_innotec/controller_api.py", line 45, in call
    response = requests.post("http://{hostname}/{endpoint}".format(hostname=self.api_host, endpoint=endpoint),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2023-11-01 03:16:45.175 ERROR (MainThread) [custom_components.alpha_innotec.sensor] Unexpected error fetching Alpha Sensor data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/sensor.py", line 71, in _async_update_data
    return await self.get_thermostats(self.hass, self.gateway_api, self.controller_api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 64, in get_thermostats
    raise exception
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 26, in get_thermostats
    room_list: dict = await hass.async_add_executor_job(controller_api.room_list)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 97, in room_list
    return self.call("api/room/list")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 59, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2023-11-01 03:16:48.249 ERROR (MainThread) [custom_components.alpha_innotec.climate] Unexpected error fetching Alpha Sensor data: Failed to get data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/climate.py", line 73, in _async_update_data
    return await self.get_thermostats(self.hass, self.gateway_api, self.controller_api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 64, in get_thermostats
    raise exception
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 21, in get_thermostats
    rooms: dict = await hass.async_add_executor_job(gateway_api.all_modules)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 87, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 70, in call
    raise Exception('Failed to get data')
Exception: Failed to get data
2023-11-01 03:48:14.940 ERROR (SyncWorker_1) [custom_components.alpha_innotec.gateway_api] Unable to fetch data from API: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/dbmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f60847ed0>: Failed to establish a new connection: [Errno 111] Connection refused'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.11/http/client.py", line 1286, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1332, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1281, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1041, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.11/http/client.py", line 979, in send
    self.connect()
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f60847ed0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/dbmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f60847ed0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 54, in call
    response = requests.post("http://{hostname}/{endpoint}".format(hostname=self.api_host, endpoint=endpoint),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/dbmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f60847ed0>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-11-01 03:48:14.957 ERROR (MainThread) [custom_components.alpha_innotec.binary_sensor] Unexpected error fetching Alpha Innotec Binary Coordinator data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/binary_sensor.py", line 65, in _async_update_data
    db_modules: dict = await self.hass.async_add_executor_job(self.gateway_api.db_modules)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 93, in db_modules
    return self.call("api/gateway/dbmodules")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 69, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2023-11-01 03:48:25.815 ERROR (SyncWorker_6) [custom_components.alpha_innotec.gateway_api] Unable to fetch data from API: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/allmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6ad09c10>: Failed to establish a new connection: [Errno 111] Connection refused'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.11/http/client.py", line 1286, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1332, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1281, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1041, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.11/http/client.py", line 979, in send
    self.connect()
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f6ad09c10>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/allmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6ad09c10>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 54, in call
    response = requests.post("http://{hostname}/{endpoint}".format(hostname=self.api_host, endpoint=endpoint),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/allmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6ad09c10>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-11-01 03:48:25.835 ERROR (MainThread) [custom_components.alpha_innotec.sensor] Unexpected error fetching Alpha Sensor data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/sensor.py", line 71, in _async_update_data
    return await self.get_thermostats(self.hass, self.gateway_api, self.controller_api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 64, in get_thermostats
    raise exception
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 21, in get_thermostats
    rooms: dict = await hass.async_add_executor_job(gateway_api.all_modules)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 87, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 69, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2023-11-01 03:48:28.950 ERROR (SyncWorker_3) [custom_components.alpha_innotec.gateway_api] Unable to fetch data from API: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/allmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6748a950>: Failed to establish a new connection: [Errno 111] Connection refused'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.11/http/client.py", line 1286, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1332, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1281, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.11/http/client.py", line 1041, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.11/http/client.py", line 979, in send
    self.connect()
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f6748a950>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/allmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6748a950>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 54, in call
    response = requests.post("http://{hostname}/{endpoint}".format(hostname=self.api_host, endpoint=endpoint),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/allmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6748a950>: Failed to establish a new connection: [Errno 111] Connection refused'))
2023-11-01 03:48:28.972 ERROR (MainThread) [custom_components.alpha_innotec.climate] Unexpected error fetching Alpha Sensor data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/climate.py", line 73, in _async_update_data
    return await self.get_thermostats(self.hass, self.gateway_api, self.controller_api)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 64, in get_thermostats
    raise exception
  File "/config/custom_components/alpha_innotec/base_coordinator.py", line 21, in get_thermostats
    rooms: dict = await hass.async_add_executor_job(gateway_api.all_modules)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 87, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 69, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
@arjenbos
Copy link
Owner

arjenbos commented Nov 1, 2023

Maybe we can reduce the number of API calls when there is only one coordinator - #19. Hopefully this will help.

@arnebret
Copy link
Author

arnebret commented Nov 6, 2023

Great work on moving to one coordinator for the API calls, but it doesn't seem to have any effect. I don't think this local API would be rate limited (or at least not at the number of calls we're doing).

It still seems to do exactly the same thing on exactly the same time:

2023-11-06 03:16:49.560 ERROR (SyncWorker_6) [custom_components.alpha_innotec.controller_api] Unable to fetch data from API: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

2023-11-06 03:48:21.649 ERROR (SyncWorker_6) [custom_components.alpha_innotec.gateway_api] Unable to fetch data from API: HTTPConnectionPool(host='192.168.1.192', port=80): Max retries exceeded with url: /api/gateway/dbmodules (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5c883d50>: Failed to establish a new connection: [Errno 111] Connection refused'))

So two different errors but always at the same time of 03:16 and 03:48.

I'm starting to wonder if the Alpha Home Gateway and Controller have some built-in reset or reboot every night at these times. That said, if nobody else sees this behaviour it might have something to do with my specific installation.

Is anybody seeing something similar?

@ChrisMisker
Copy link
Contributor

ChrisMisker commented Nov 6, 2023

Yes, I see the same behavior as well. Never noticed it, I’m usually asleep during that time. ;-) But I see it in the HA logbook that the devices become unavailable for a couple of seconds.

Any way I can help debug?

@arjenbos
Copy link
Owner

arjenbos commented Nov 6, 2023

If there is a rate limit, then we will see this behavior throughout the day. The coordinator updates every minute. Maybe one of you can run a ping to the gateway/controller for a night?

@DrBlokmeister
Copy link

I checked it with a ping sensor for two nights. No timeouts whatsoever to the heatpump, controller or gateway.

@arnebret
Copy link
Author

I checked it with a ping sensor for two nights. No timeouts whatsoever to the heatpump, controller or gateway.

Confirmed, I see the same things in my logs. Did a ping cycle on all three, all kept giving responses in the <500 ms range. I was even awake for one of the cycles (don't ask) and saw the gateway and controller were both on.

So it seems a software thing that does a nightly cycle. The Alpha Home software isn't great, so I'm not surprised that they're using hacky solutions like this.

I don't think we can solve the issue other than building in a little more leeway before the entities become unavailable. So maybe do something like a 90 second timeout (3 refresh cycles) for these specific errors. They normally recover within a minute, so 90 seconds should work just fine. If more than 90 seconds have passed we probably have an actual issue.

@arjenbos
Copy link
Owner

arjenbos commented Nov 27, 2023

Is it possible that one of you pulls the latest version from the main branch? I added a retry strategy.

@arjenbos arjenbos mentioned this issue Nov 27, 2023
@arnebret
Copy link
Author

Thanks, have just installed it here, will see what happens overnight and report back

@arnebret
Copy link
Author

Looking very promising, I do see a 'failed to get data; entry in the log (attached below), but the actual entities do not show the errors in the logbook and do not become unknown right away. This removes a lot of unnecessary clutter and errors from the logbook and logs, so I would say this is a success.

This error originated from a custom integration.

Logger: custom_components.alpha_innotec.coordinator
Source: helpers/update_coordinator.py:290
Integration: Alpha Innotec (documentation, issues)
First occurred: 03:16:26 (1 occurrences)
Last logged: 03:16:26

Unexpected error fetching Alpha Innotec data: Failed to get data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/coordinator.py", line 34, in _async_update_data
    all_modules: dict = await self.hass.async_add_executor_job(self.gateway_api.all_modules)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 85, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 70, in call
    raise Exception('Failed to get data')
Exception: Failed to get data

@arnebret
Copy link
Author

It does seem that in some cases a connection error still renders the entities unavailable. I have attached the log file for an event that rendered the entities unavailable. The second time the connection was refused I do see some errors in the log, but the entities did not become unavailable.

This rendered the climate entities unavailable:

This error originated from a custom integration.

Logger: custom_components.alpha_innotec.coordinator
Source: helpers/update_coordinator.py:290
Integration: Alpha Innotec (documentation, issues)
First occurred: 03:16:53 (1 occurrences)
Last logged: 03:16:53

Unexpected error fetching Alpha Innotec data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/coordinator.py", line 35, in _async_update_data
    room_list: dict = await self.hass.async_add_executor_job(self.controller_api.room_list)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 101, in room_list
    return self.call("api/room/list")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 59, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

This did not:

This error originated from a custom integration.

Logger: urllib3.connectionpool
Source: custom_components/alpha_innotec/gateway_api.py:54
Integration: Alpha Innotec (documentation, issues)
First occurred: 03:48:30 (8 occurrences)
Last logged: 03:48:53

Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5c6c8190>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/gateway/dbmodules
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7c837110>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/gateway/dbmodules
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5e4e53d0>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/gateway/dbmodules
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5e4c2f50>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/gateway/dbmodules
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5c71e390>: Failed to establish a new connection: [Errno 111] Connection refused')': /api/gateway/dbmodules

@arjenbos
Copy link
Owner

This error originated from a custom integration.

Logger: custom_components.alpha_innotec.coordinator
Source: helpers/update_coordinator.py:290
Integration: Alpha Innotec (documentation, issues)
First occurred: 03:16:53 (1 occurrences)
Last logged: 03:16:53

Unexpected error fetching Alpha Innotec data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/coordinator.py", line 35, in _async_update_data
    room_list: dict = await self.hass.async_add_executor_job(self.controller_api.room_list)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 101, in room_list
    return self.call("api/room/list")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/controller_api.py", line 59, in call
    if not json_response['success']:
           ~~~~~~~~~~~~~^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Ah, in this case we received a response from the API, but not a response that contains JSON.

@DrBlokmeister
Copy link

I decided to do a bit more digging yesterday. I added a few more error logging statements to the api and coordinator code, and found this error when the connection drops:

2024-10-28 08:18:32.115 ERROR (SyncWorker_49) [custom_components.alpha_innotec.gateway_api] [api/gateway/allmodules] - API call unsuccessful: {'success': False, 'message': 'Currently there is no connection between Gateway and Control Box. Without a connection radio components can not be operated.', 'loginRejected': False, 'language': 'en', 'performance': 0.284}
2024-10-28 08:18:32.116 ERROR (SyncWorker_49) [custom_components.alpha_innotec.gateway_api] Error fetching all modules: Failed to get data from API endpoint: api/gateway/allmodules
2024-10-28 08:18:32.118 ERROR (MainThread) [custom_components.alpha_innotec.coordinator] Exception in coordinator update: Failed to get data from API endpoint: api/gateway/allmodules
Traceback (most recent call last):
  File "/config/custom_components/alpha_innotec/coordinator.py", line 35, in _async_update_data
    all_modules: dict = await self.hass.async_add_executor_job(self.gateway_api.all_modules)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 94, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 72, in call
    raise Exception('Failed to get data from API endpoint: {}'.format(endpoint))
Exception: Failed to get data from API endpoint: api/gateway/allmodules
2024-10-28 08:18:32.122 ERROR (MainThread) [custom_components.alpha_innotec.coordinator] Unexpected error fetching Alpha Innotec data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/coordinator.py", line 35, in _async_update_data
    all_modules: dict = await self.hass.async_add_executor_job(self.gateway_api.all_modules)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 94, in all_modules
    response = self.call("api/gateway/allmodules")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alpha_innotec/gateway_api.py", line 72, in call
    raise Exception('Failed to get data from API endpoint: {}'.format(endpoint))
Exception: Failed to get data from API endpoint: api/gateway/allmodules

It seems to me that HA can connect to the gateway just fine, but the gateway cannot reach the control box. A minute later, the sensors update just fine again.

I updated my ping sensors to ping more often and check if the control box drops off during these times of unavailability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants