gazoodle / gecko-home-assistant

Home Assistant integration for spas equipped with Gecko Alliance in.touch2 modules
MIT License
69 stars 24 forks source link

Failed to set up: RuntimeError: I/O must be done in the executor (workaround and fix) #25

Closed rct closed 3 years ago

rct commented 3 years ago

Version of the custom_component

Version 0.0.5 - from manifest.json Version 0.0.1 - from const.py

Configuration

NA - Configured through UI

Describe the bug

With the current version of the Gecko custom component (0.0.5), as of 2021-06-14, the Gecko integration will fail to set up in Home Assistant due to trying to download SpaPackStruct.xml when the component is starting up.

To fix the problem, apply the change in PR #24 to custom_components/gecko/__init__.py in your Home Assistant configuration directory. The configuration directory path is often /config or /usr/share/hassio/homeassistant/config but may be different based on installation method or the way you are accessing the files.

You can download the patched file directly from the PR https://github.com/gazoodle/gecko-home-assistant/blob/a7ad5024a656f01525a4d4340be9e1d7c8caf910/custom_components/gecko/__init__.py

(The fix was provided originally by @EiNSTeiN- in #15. The problem was also reported in #7 and #9.)

A workaround that doesn't require changing the code is to manually download SpaPackStruct.xml and a place a copy in your Home Assistant configuration directory. (Note the correct directory is the top level configuration directory, not the custom_component/gecko directory. This is the same directory that contains configuration.yaml. Use curl or wget to download http://intouch.geckoal.com/gecko/prod/SpaPackStruct.xml

Note: this information was originally in issue #15. I've moved the information about the fix and the workaround here to make it easier for people to quickly find without having to sort through a long issue.

Note 2: The SpaPackStruct.xml that is currently available for download is version 19, which is somewhat out-of-date, but appears to be the last version easily accessible without having to extract it from the mobile app. Some new spa controllers (spa packs) will require an updated SpaPackStruct.xml to work correctly.

Debug log


Exception during entry setup
Traceback (most recent call last):
  File "/config/custom_components/gecko/__init__.py", line 45, in async_setup_entry
    facade = locator.get_spa_from_identifier(spa_identifier).get_facade(False)
  File "/usr/local/lib/python3.8/site-packages/geckolib/spa.py", line 46, in get_facade
    facade = GeckoFacade(GeckoSpa(self).start_connect())
  File "/usr/local/lib/python3.8/site-packages/geckolib/spa.py", line 73, in __init__
    GeckoSpaPack.__init__(self)
  File "/usr/local/lib/python3.8/site-packages/geckolib/driver/spapack.py", line 15, in __init__
    GeckoSpaPack.download_if_needed()
  File "/usr/local/lib/python3.8/site-packages/geckolib/driver/spapack.py", line 32, in download_if_needed
    GeckoSpaPack.download()
  File "/usr/local/lib/python3.8/site-packages/geckolib/driver/spapack.py", line 39, in download
    response = http.request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/request.py", line 74, in request
    return self.request_encode_url(
  File "/usr/local/lib/python3.8/site-packages/urllib3/request.py", line 96, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.8/site-packages/urllib3/poolmanager.py", line 375, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.8/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.8/http/client.py", line 1266, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connection.py", line 214, in putrequest
    return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 150, in protected_loop_func
    check_loop()
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 139, in check_loop
    raise RuntimeError(
RuntimeError: I/O must be done in the executor; Use `await hass.async_add_executor_job()` at custom_components/gecko/__init__.py, line 45: facade = locator.get_spa_from_identifier(spa_identifier).get_facade(False)
gazoodle commented 3 years ago

This should be fixed from v0.0.6 onwards