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

Integration Failed to Setup when no internet #165

Open
gregorymartin opened this issue Sep 8, 2024 · 6 comments
Open

Integration Failed to Setup when no internet #165

gregorymartin opened this issue Sep 8, 2024 · 6 comments

Comments

@gregorymartin
Copy link
Contributor

I recently had a significant internet outage and in the past this integration worked fine in that instance, 100% locally. This time around it is showing a “failed to setup” message and all my units are “unavailable”. There is probably an opportunity to test under these circumstances and ensure setup doesn’t rely on the cloud platform.

@dlarrick
Copy link
Owner

dlarrick commented Sep 8, 2024

Hmm that's odd. It should not contact Kumo Cloud at all, ever, once initially set up, if "prefer cache" is turned on. If that's no longer true, we should definitely fix it.

I suppose it's possible Mitsubishi has changed something such that the indoor units lose their IP address if they can't phone home. If that's what's going on here, not much we can do about it.

@gregorymartin
Copy link
Contributor Author

Yeah, our internet will remain down until Saturday, so if there is something I can pull from the logs that could help here, let me know.

@dlarrick
Copy link
Owner

dlarrick commented Sep 9, 2024

If you're willing, follow the procedure on the pykumo README, supplying it with your kumo_cache.py rather than having it prompt you.
account = pykumo.KumoCloudAccount(username, password, kumo_dict=cached_json)

Then see if you can talk to your indoor unit(s). That should tell us if the problem is with hass-kumo or if they're just inaccessible when offline.

@gregorymartin
Copy link
Contributor Author

I will give that a shot. In the meantime, here is the exception that is getting logged when trying to reload the integration. It looks like it may have something unhandled in the flow that throws when internet connectivity is down:

2024-09-09 18:10:05.845 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry for kumo
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/socket.py", line 964, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 716, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 404, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 1061, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 363, in connect
self.sock = conn = self._new_conn()
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno -3] Try again
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 802, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/urllib3/util/retry.py", line 594, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='geo-c.kumocloud.com', port=443): Max retries exceeded with url: /login (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Try again'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/kumo/init.py", line 79, in async_setup_entry
account = await async_kumo_setup(hass, prefer_cache, username, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/kumo/init.py", line 119, in async_kumo_setup
setup_success = await hass.async_add_executor_job(account.try_setup)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pykumo/py_kumo_cloud_account.py", line 116, in try_setup
self._fetch_if_needed()
File "/usr/local/lib/python3.12/site-packages/pykumo/py_kumo_cloud_account.py", line 80, in _fetch_if_needed
response = requests.post(self._url, headers=headers, data=json.dumps(body),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='geo-c.kumocloud.com', port=443): Max retries exceeded with url: /login (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Try again'))

@gregorymartin
Copy link
Contributor Author

Ok, so I dug into my core.config_entries file, and I did not have prefer_cache set to true. I changed that and rebooted, and everything is back online. This may be an opportunity for a fallback mode when perfer_cache isn't turned on to prefer the cache still when the internet can't be reached. Also, there isn't a way to set prefer_cache from the UI after initial setup, from what I can find. Is that true?

@dlarrick
Copy link
Owner

dlarrick commented Sep 10, 2024

I'm glad it's working for you now, and I hope your Internet comes back w/o issue.

The behavior here is the result of evolution of control, and also choosing strategy in the face of unreliability. Originally it was in YAML and people could override the IP address, which units to control, even the "password" that's used at a low level. But discoverability is better for the majority of folks so now it gets those things from the cloud -- which usually works.

But yeah, some different behavior might be preferable:

  • Always prefer cache if it's present
  • If one or more units can't be reached at all (connection failure), try to refresh from the cloud. Only populate info that works properly into the cache.
  • Continue to provide UI to override the IP addresses since that does seem to be a common issue

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

No branches or pull requests

2 participants