Tuya failed to setup after restart due to unkown error

Hi,

After a restart of home assistant, the Tuya integration failed to setup. Everything was working fine before the reboot. I am on core-2021.11.2 and the smartlife app is still working fine. I tried to clear the cache, tried resetting my smartlife password and even removed the integration and reinstalled. Nothing works.

Is anyone else having issue? Is this a tuya issue again?

image

The logs show:

Source: components/tuya/__init__.py:66
First occurred: 5:07:30 PM (1 occurrences)
Last logged: 5:07:30 PM

Error setting up entry [email protected] for tuya
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/tuya/__init__.py", line 66, in async_setup_entry
    hass.data[DOMAIN].pop(entry.entry_id)
KeyError: '25a809e282b5a5ec7921c3af4b06de6b'

Just had something similar. Was getting errors like this in the log whenever I tried to operate my Tuya covers:

'Response' object has no attribute 'body'

Tried re-installing the integration with the current Tuya IoT platform project, but kept getting ’ Failed with unknown error’ messages. Ended up deleting the integration, creating an entirely new project on the Tuya IoT platform according to the guide, and everything seems to be back again.

I only have 2 devices though, so I imagine this could be painful if you have many devices.

Definitely something on the Tuya side I would say.

I’ve just posted something similar, i’m seeing the same. But really don’t want to go to those lengths! Hope it gets sorted out on the Tuya side

I also have this message. Maybe it is again a tuya error. Smart Life app is still working fine but home assistant and my Alexa is not working. I think I will just wait and see.

Well, it works again. What I did was:

  • disable the integration in HA (not uninstall, just disable)
  • changed my password in the smartlife app to something new and then back again to the original one
  • enabled the integration again in HA.

Now it works again. Of course it could be just coincidence and maybe it was a brief hickup at tuya side? I did lose my scenes in the tuya integration (there are now fewer devices and entities), but oddly enough, my scenes actually still work. The scene entities are still there, they are just under the “scene” integration. No idea why, but as long as they work, I am not complaining :smiley:

Very similar error.
Just ran an update for the OS and Core (first in about 3 months). Had just tested a lamp and switch (the lamp was slow to appear after getting power on), so decided to update and see if I could get a faster response on the Tuyta stuff. Now I’ve got NO response.

So now it is working again. Just a restart and everything is back again and working.

If you really haven’t updated for about 3 months before now, then you need to look at the breaking changes for the October HA core 2021.10 release … in brief the Tuya integration has been completely changed.

1 Like

Thank you.
That would explain it. I’ll follow the guide and set it up again.

Normally I would be updating at least once a month, but there’s been lots of more serious stuff to attend to at home.

Thanks. I just went through the same issue. I had an outage and all my Tuya devices became unavailable.

The fix for me was similar to the above except for the password change:

  1. Disabled (not Delete) the Tuya integration
    Option in the Configuration/Integrations tab.
    This may make the integration disappear from the Integrations tab.

  2. Re-Enabled the Tuya integration
    See the option top right of screen to show disabled integrations if it is not showing.
    The Integration box will have the 3 small dots at bottom right to select options.

  3. Restarted the HA server (after checking HA configuration was valid).
    This is from Configuration/Server Controls

I made no changes to the Tuya Smart Life app or password.

After the restart all devices became available and previous automations are still in place.

im having this problem my self. setup the account and followed the guides online but keeps giving me unkown error

Same here

log:

Logger: aiohttp.server
Source: components/tuya/config_flow.py:72
First occurred: 20:52:01 (2 occurrences)
Last logged: 20:52:23

Error handling request
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 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, 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.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x9f1e14c0>: 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.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='openapi.tuyaeu.com', port=443): Max retries exceeded with url: /v1.0/iot-03/users/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x9f1e14c0>: 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.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 82, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 280, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/tuya/config_flow.py", line 92, in async_step_user
    response, data = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/tuya/config_flow.py", line 72, in _try_login
    response = api.connect(
  File "/usr/local/lib/python3.10/site-packages/tuya_iot/openapi.py", line 198, in connect
    response = self.post(
  File "/usr/local/lib/python3.10/site-packages/tuya_iot/openapi.py", line 316, in post
    return self.__request("POST", path, None, body)
  File "/usr/local/lib/python3.10/site-packages/tuya_iot/openapi.py", line 266, in __request
    response = self.session.request(
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='openapi.tuyaeu.com', port=443): Max retries exceeded with url: /v1.0/iot-03/users/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x9f1e14c0>: Failed to establish a new connection: [Errno -3] Try again'))

Having the same issue here. I can’t add the integration. I used to have it but had problems with it. I disabled and enabled but still not working. Deleted it and even deleted de project and created a new one. Same answer “unknown error”. I tried also changing the Smart life app password. Nothing. It’s even 3 months now and I have no clue on how to continue.

I have even burned a new Home Assistant on a new SD to check if it was some problem with my configuration of Home Assistant.

I checked the country, the ID and secret, the devices in the Tuya IoT Project that are correct… If anyone has some Idea it would be great.

My Smart Life apk . Project - Linked
:thinking:

Yes, I think this means your your Smart Life App is linked with the IoT platform, but this does not determine if the integration between HASSIO and Tuya IoT platform is working. I have it linked too :confused:

Thew log I get:

Logger: aiohttp.server
Source: components/tuya/config_flow.py:72
First occurred: 17:32:24 (1 occurrences)
Last logged: 17:32:24

Error handling request
Traceback (most recent call last):
File “/usr/local/lib/python3.11/site-packages/urllib3/connection.py”, line 174, in _new_conn
conn = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/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.11/socket.py”, line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -5] Name has no usable address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
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 403, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py”, line 1053, in _validate_conn
conn.connect()
File “/usr/local/lib/python3.11/site-packages/urllib3/connection.py”, line 363, in connect
self.sock = conn = self._new_conn()
^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/urllib3/connection.py”, line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f88dc3d90>: Failed to establish a new connection: [Errno -5] Name has no usable address

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 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘openapi.tuyaeu.com’, port=443): Max retries exceeded with url: /v1.0/iot-03/users/login (Caused by NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x7f88dc3d90>: Failed to establish a new connection: [Errno -5] Name has no usable address’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py”, line 433, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py”, line 504, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py”, line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/security_filter.py”, line 85, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/forwarded.py”, line 100, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/request_context.py”, line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/ban.py”, line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 236, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 148, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/config/config_entries.py”, line 181, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/http/data_validator.py”, line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py”, line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 296, in async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 392, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/tuya/config_flow.py”, line 92, in async_step_user
response, data = 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/src/homeassistant/homeassistant/components/tuya/config_flow.py”, line 72, in _try_login
response = api.connect(
^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/tuya_iot/openapi.py”, line 198, in connect
response = self.post(
^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/tuya_iot/openapi.py”, line 316, in post
return self.__request(“POST”, path, None, body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/tuya_iot/openapi.py”, line 266, in __request
response = self.session.request(
^^^^^^^^^^^^^^^^^^^^^
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 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘openapi.tuyaeu.com’, port=443): Max retries exceeded with url: /v1.0/iot-03/users/login (Caused by NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x7f88dc3d90>: Failed to establish a new connection: [Errno -5] Name has no usable address’))