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

Handle connection errors gracefully #57

Open
hmmbob opened this issue Sep 7, 2023 · 3 comments
Open

Handle connection errors gracefully #57

hmmbob opened this issue Sep 7, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@hmmbob
Copy link
Contributor

hmmbob commented Sep 7, 2023

Every now and then HA doesn't get an answer from any of my airco's (I have 4) and throws a long error. It would be great if this error is caught and handled nicely.

2023-09-07 09:26:50.772 ERROR (MainThread) [custom_components.mitsubishi_wf_rac.wfrac.device] Error: something went wrong updating the airco [Airco ec0baefc92e4] values
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 466, 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 461, 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 279, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/socket.py", line 706, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out
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 798, 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 770, in reraise
raise value
File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 468, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 357, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.1.221', port=51443): Read timed out. (read timeout=30)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/mitsubishi_wf_rac/wfrac/device.py", line 53, in update
response = await self._api.get_aircon_stats()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/mitsubishi_wf_rac/wfrac/repository.py", line 110, in get_aircon_stats
result = await self._post("getAirconStat")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/mitsubishi_wf_rac/wfrac/repository.py", line 66, in _post
response = await self._hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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 532, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.1.221', port=51443): Read timed out. (read timeout=30)
@jeatheak jeatheak added the bug Something isn't working label Sep 7, 2023
@vaneeten
Copy link

First of all, thank you for taking the trouble to write this integration!

I'm having a very similar problem here, also with 4 airco units. After about every reboot, one of the four does not come to live, with a log message like this:

Logger: custom_components.mitsubishi_wf_rac.wfrac.device
Source: custom_components/mitsubishi_wf_rac/wfrac/repository.py:66 
Integration: Mitsubishi WF-RAC ([documentation](https://github.com/jeatheak/Mitsubishi-WF-RAC-Integration/)) 
First occurred: 4:34:35 PM (1 occurrences) 
Last logged: 4:34:35 PM

Error: something went wrong updating the airco [Airco werkkamer] values
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

which then triggers a cascade of errors in the log.

It's not always the same unit that doesn't work. Sometimes, after a series of HA restarts, all 4 work so I wouldn't expect some actual incompatibility. As the official Smart M-Air app itself also takes several seconds to connect to the 4 units,
and even had some real trouble keeping all 4 units connected when I didn't use their cloud account yet, I suspect that connection failures are to be expected and retried periodically with this interface.

@KixAss
Copy link

KixAss commented Feb 2, 2024

First of all, thank you for taking the trouble to write this integration!

I'm having a very similar problem here, also with 4 airco units. After about every reboot, one of the four does not come to live, with a log message like this:

Logger: custom_components.mitsubishi_wf_rac.wfrac.device
Source: custom_components/mitsubishi_wf_rac/wfrac/repository.py:66 
Integration: Mitsubishi WF-RAC ([documentation](https://github.com/jeatheak/Mitsubishi-WF-RAC-Integration/)) 
First occurred: 4:34:35 PM (1 occurrences) 
Last logged: 4:34:35 PM

Error: something went wrong updating the airco [Airco werkkamer] values
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

which then triggers a cascade of errors in the log.

It's not always the same unit that doesn't work. Sometimes, after a series of HA restarts, all 4 work so I wouldn't expect some actual incompatibility. As the official Smart M-Air app itself also takes several seconds to connect to the 4 units, and even had some real trouble keeping all 4 units connected when I didn't use their cloud account yet, I suspect that connection failures are to be expected and retried periodically with this interface.

Same problem here. 3 units and often when I reboot Home Assistant, 1 of 2 don't connect.

airco log.txt

@vinzouilleus
Copy link

First of all, thank you for taking the trouble to write this integration!
I'm having a very similar problem here, also with 4 airco units. After about every reboot, one of the four does not come to live, with a log message like this:

Logger: custom_components.mitsubishi_wf_rac.wfrac.device
Source: custom_components/mitsubishi_wf_rac/wfrac/repository.py:66 
Integration: Mitsubishi WF-RAC ([documentation](https://github.com/jeatheak/Mitsubishi-WF-RAC-Integration/)) 
First occurred: 4:34:35 PM (1 occurrences) 
Last logged: 4:34:35 PM

Error: something went wrong updating the airco [Airco werkkamer] values
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

which then triggers a cascade of errors in the log.
It's not always the same unit that doesn't work. Sometimes, after a series of HA restarts, all 4 work so I wouldn't expect some actual incompatibility. As the official Smart M-Air app itself also takes several seconds to connect to the 4 units, and even had some real trouble keeping all 4 units connected when I didn't use their cloud account yet, I suspect that connection failures are to be expected and retried periodically with this interface.

Same problem here. 3 units and often when I reboot Home Assistant, 1 of 2 don't connect.

airco log.txt

Same here as well. After a HA Core update for example, I typically have to restart HA a few more times to ensure all AC entities are visible again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants