freeranger / evologger

EvoHome Logger
MIT License
12 stars 4 forks source link

Netatmo plugin occasionally fails to get a response object #14

Open freeranger opened 2 years ago

freeranger commented 2 years ago

Logs:

2022-02-14 04:43:27 | stdout | AttributeError: 'NoneType' object has no attribute 'status_code'
-- | -- | --
2022-02-14 04:43:27 | stdout | logger.exception(f'Error at {full_url} {e.response.status_code} {e.response.reason} {e.response.json()} - aborting read\nError: {e}')
2022-02-14 04:43:27 | stdout | File "./plugins/netatmo/__init__.py", line 40, in _post_request
2022-02-14 04:43:27 | stdout | response = _post_request('api/getstationsdata', { 'access_token' : access_token }, self._logger)
2022-02-14 04:43:27 | stdout | File "./plugins/netatmo/__init__.py", line 214, in _read_temperatures
2022-02-14 04:43:27 | stdout | Traceback (most recent call last):
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | During handling of the above exception, another exception occurred:
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.netatmo.com', port=443): Max retries exceeded with url: /api/getstationsdata (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f186656b880>: Failed to establish a new connection: [Errno 111] Connection refused'))
2022-02-14 04:43:27 | stdout | raise ConnectionError(e, request=request)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
2022-02-14 04:43:27 | stdout | r = adapter.send(request, **kwargs)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
2022-02-14 04:43:27 | stdout | resp = self.send(prep, **send_kwargs)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
2022-02-14 04:43:27 | stdout | return session.request(method=method, url=url, **kwargs)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
2022-02-14 04:43:27 | stdout | return request('post', url, data=data, json=json, **kwargs)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 117, in post
2022-02-14 04:43:27 | stdout | with requests.post(full_url, headers= {
2022-02-14 04:43:27 | stdout | File "./plugins/netatmo/__init__.py", line 29, in _post_request
2022-02-14 04:43:27 | stdout | Traceback (most recent call last):
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | During handling of the above exception, another exception occurred:
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.netatmo.com', port=443): Max retries exceeded with url: /api/getstationsdata (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f186656b880>: Failed to establish a new connection: [Errno 111] Connection refused'))
2022-02-14 04:43:27 | stdout | raise MaxRetryError(_pool, url, error or ResponseError(cause))
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
2022-02-14 04:43:27 | stdout | retries = retries.increment(
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen
2022-02-14 04:43:27 | stdout | resp = conn.urlopen(
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
2022-02-14 04:43:27 | stdout | Traceback (most recent call last):
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | During handling of the above exception, another exception occurred:
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f186656b880>: Failed to establish a new connection: [Errno 111] Connection refused
2022-02-14 04:43:27 | stdout | raise NewConnectionError(
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
2022-02-14 04:43:27 | stdout | conn = self._new_conn()
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
2022-02-14 04:43:27 | stdout | conn.connect()
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
2022-02-14 04:43:27 | stdout | self._validate_conn(conn)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request
2022-02-14 04:43:27 | stdout | httplib_response = self._make_request(
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
2022-02-14 04:43:27 | stdout | Traceback (most recent call last):
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | During handling of the above exception, another exception occurred:
2022-02-14 04:43:27 | stdout |  
2022-02-14 04:43:27 | stdout | ConnectionRefusedError: [Errno 111] Connection refused
2022-02-14 04:43:27 | stdout | sock.connect(sa)
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
2022-02-14 04:43:27 | stdout | raise err
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 95, in create_connection
2022-02-14 04:43:27 | stdout | conn = connection.create_connection(
2022-02-14 04:43:27 | stdout | File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
2022-02-14 04:43:27 | stdout | Traceback (most recent call last):
2022-02-14 04:43:27 | stdout | 'NoneType' object has no attribute 'status_code' [Netatmo-plugin]
2022-02-14 04:43:27 | stdout | 2022-02-14 04:43:27 [error    ] Netatmo API error - aborting read:
freeranger commented 2 years ago

Different example (500 response):

2022-02-20 10:55:31 | stdout | Exception: Failed to retrieve station data
-- | -- | --
2022-02-20 10:55:31 | stdout | raise Exception('Failed to retrieve station data')
2022-02-20 10:55:31 | stdout | File "./plugins/netatmo/__init__.py", line 216, in _read_temperatures
2022-02-20 10:55:31 | stdout | Traceback (most recent call last):
2022-02-20 10:55:31 | stdout | Failed to retrieve station data [Netatmo-plugin]
2022-02-20 10:55:31 | stdout | 2022-02-20 10:55:31 [error    ] Netatmo API error - aborting read:
2022-02-20 10:55:31 | stdout | requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://api.netatmo.com/api/getstationsdata
2022-02-20 10:55:31 | stdout | raise HTTPError(http_error_msg, response=self)
2022-02-20 10:55:31 | stdout | File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 960, in raise_for_status
2022-02-20 10:55:31 | stdout | response.raise_for_status()
2022-02-20 10:55:31 | stdout | File "./plugins/netatmo/__init__.py", line 33, in _post_request
2022-02-20 10:55:31 | stdout | Traceback (most recent call last):
2022-02-20 10:55:31 | stdout | Error: 500 Server Error: Internal Server Error for url: https://api.netatmo.com/api/getstationsdata [Netatmo-plugin]
2022-02-20 10:55:31 | stdout | 2022-02-20 10:55:31 [error    ] HTTPError at https://api.netatmo.com/api/getstationsdata - 500 Internal Server Error {'error': {'code': 500, 'message': 'Internal Server Error'}} - aborting read
2