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

Error during setup of component xiaomi_miot #314

Closed
booroondook-eng opened this issue Dec 19, 2021 · 7 comments
Closed

Error during setup of component xiaomi_miot #314

booroondook-eng opened this issue Dec 19, 2021 · 7 comments

Comments

@booroondook-eng
Copy link

booroondook-eng commented Dec 19, 2021

After upgrade xiaomi_miot to 0.4.14 integration doesn't work with multiple errors in the log:

Logger: homeassistant.setup
Source: custom_components/xiaomi_miot/core/xiaomi_cloud.py:409
Integration: Xiaomi Miot Auto (documentation, issues)
First occurred: 12:33:01 (1 occurrences)
Last logged: 12:33:01

Error during setup of component xiaomi_miot
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.9/socket.py", line 954, 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.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f42e8bc92e0>: 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.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ru', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f42e8bc92e0>: 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/setup.py", line 229, in _async_setup_component
    result = await task
  File "/config/custom_components/xiaomi_miot/__init__.py", line 211, in async_setup
    hass.data[DOMAIN]['devices_by_mac'] = await mic.async_get_devices_by_key('mac') or {}
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 248, in async_get_devices_by_key
    dvs = await self.async_get_devices(renew=renew) or []
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 222, in async_get_devices
    dvs = await self.hass.async_add_executor_job(self.get_device_list)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 181, in get_device_list
    rdt = self.request_miot_api('home/device_list', {
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 151, in request_miot_api
    rsp = self.request(self.get_api_url(api), params)
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 409, in request
    response = self.session.post(url, data=post_data, timeout=self.http_timeout)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ru', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f42e8bc92e0>: Failed to establish a new connection: [Errno -3] Try again'))

I restored from backup version 0.4.9 files, and now all is OK.

al-one added a commit that referenced this issue Dec 20, 2021
@al-one
Copy link
Owner

al-one commented Dec 20, 2021

Please upgrade to master branch and try again.

@booroondook-eng
Copy link
Author

Please upgrade to master branch and try again.

After this upgrage the problem appears again:


Logger: homeassistant.setup
Source: custom_components/xiaomi_miot/core/xiaomi_cloud.py:410
Integration: Xiaomi Miot Auto (documentation, issues)
First occurred: 10:44:25 (1 occurrences)
Last logged: 10:44:25

Error during setup of component xiaomi_miot
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 73, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.9/socket.py", line 954, 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.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fdd477cd430>: 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.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ru', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fdd477cd430>: 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/setup.py", line 229, in _async_setup_component
    result = await task
  File "/config/custom_components/xiaomi_miot/__init__.py", line 211, in async_setup
    hass.data[DOMAIN]['devices_by_mac'] = await mic.async_get_devices_by_key('mac') or {}
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 248, in async_get_devices_by_key
    dvs = await self.async_get_devices(renew=renew) or []
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 222, in async_get_devices
    dvs = await self.hass.async_add_executor_job(self.get_device_list)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 181, in get_device_list
    rdt = self.request_miot_api('home/device_list', {
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 151, in request_miot_api
    rsp = self.request(self.get_api_url(api), params, **kwargs)
  File "/config/custom_components/xiaomi_miot/core/xiaomi_cloud.py", line 410, in request
    response = self.session.post(url, data=post_data, timeout=timeout)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='ru', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fdd477cd430>: Failed to establish a new connection: [Errno -3] Try again'))

@al-one
Copy link
Owner

al-one commented Dec 23, 2021

def request(self, url, params, **kwargs):
self.session = self.api_session()

Please modify your component local file, like this:

    def request(self, url, params, **kwargs):
        _LOGGER.warning('xiaomi miot request: %s', [url, params])
        self.session = self.api_session()

And give me the logs after restarting HA.

@al-one
Copy link
Owner

al-one commented Dec 23, 2021

In fact, the correct error report should be like this: HTTPSConnectionPool(host='ru.api.io.mi.com', port=443), but the host in your log is ru.

@al-one
Copy link
Owner

al-one commented Dec 23, 2021

Please check your configuration:

# configuration.yaml
xiaomi_miot:
  username: xiaomi_username
  password: xiaomi_password
  server_country: ru

Not:

# configuration.yaml
xiaomi_miot:
  username: xiaomi_username
  password: xiaomi_password
  server_country: http://ru # ❌  Error example

In fact, these configurations are optional. You can integrate devices through your account without yaml.
image

@booroondook-eng
Copy link
Author

booroondook-eng commented Dec 23, 2021

The problem disappeared after deleting of these entries in configuration.yaml

xiaomi_miot:
  username: xxxxxxxx@xxxxx.xxx
  password: xxxxxxxxxxx
  server_country: ru
  language: zh
  translations:
    Silence: Бесшумный
    Stanrd: Стандарт
    Middle: Средний
    Enchance: Турбо

@al-one
Copy link
Owner

al-one commented Dec 23, 2021

Just delete these entries:

  username: xxxxxxxx@xxxxx.xxx
  password: xxxxxxxxxxx
  server_country: ru

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