Tuya switches... a lot of error

Hello there, during last weeks I’m getting a lot of error with my tuya devices (added using standard component), but I can’t really see what’s going on… can someone help ? As you can see there are a lot of different errors:

Log Details (ERROR)
Mon Jun 17 2019 01:57:37 GMT+0200 (Ora legale dell’Europa centrale)

Update for switch.80241621840d8e4b51c0_1 fails

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 159, in _new_conn (self._dns_host, self.port), self.timeout, extra_kw) 
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 57, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 
  File "/usr/local/lib/python3.7/socket.py", line 748, 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.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) 
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request self._validate_conn(conn) 
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn conn.connect() File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 301, in connect conn = self._new_conn() 
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 168, in _new_conn self, "Failed to establish a new connection: %s" % e) 
  
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x6d2e61f0>: 

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.7/site-packages/requests/adapters.py", line 449, in send timeout=timeout 
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) 
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) 
  
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='px1.tuyaeu.com', port=443): Max retries exceeded with url: /homeassistant/skill (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x6d2e61f0>: 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.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state await self.async_device_update() 
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 379, in async_device_update await self.hass.async_add_executor_job(self.update) 
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) 
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/tuya/__init__.py", line 151, in update self.tuya.update() 
  File "/usr/local/lib/python3.7/site-packages/tuyapy/devices/base.py", line 43, in update self.obj_id, 'QueryDevice', namespace='query') 
  File "/usr/local/lib/python3.7/site-packages/tuyapy/tuyaapi.py", line 134, in device_control response = self._request(action, namespace, devId, param) 
  File "/usr/local/lib/python3.7/site-packages/tuyapy/tuyaapi.py", line 159, in _request json = data 
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 116, in post return request('post', url, data=data, json=json, kwargs) 
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request return session.request(method=method, url=url, kwargs) 
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request resp = self.send(prep, send_kwargs) 
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send r = adapter.send(request, kwargs) 
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) 
  
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='px1.tuyaeu.com', port=443): Max retries exceeded with url: /homeassistant/skill (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x6d2e61f0>: Failed to establish a new connection: [Errno -3] Try again'))


Log Details (ERROR)
Mon Jun 17 2019 10:42:53 GMT+0200 (Ora legale dell’Europa centrale)

Update for switch.80241621840d8e4b51c0_1 fails

Traceback (most recent call last): 
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state await self.async_device_update() 
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 379, in async_device_update await self.hass.async_add_executor_job(self.update) 
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) 
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/tuya/__init__.py", line 151, in update self.tuya.update() 
  File "/usr/local/lib/python3.7/site-packages/tuyapy/devices/base.py", line 43, in update self.obj_id, 'QueryDevice', namespace='query') 
  File "/usr/local/lib/python3.7/site-packages/tuyapy/tuyaapi.py", line 134, in device_control response = self._request(action, namespace, devId, param) 
  File "/usr/local/lib/python3.7/site-packages/tuyapy/tuyaapi.py", line 161, in _request response_json = response.json() 
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json return complexjson.loads(self.text, kwargs) 
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 518, in loads return _default_decoder.decode(s) 
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) 
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) 
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thanks in advance…

network problems - either at your end, or the px1.tuyaeu.com server…

Hi, anyone has review this ? I also have the same problems with switchs (smart power strips) does not get status updated.

It not looks like network errors because lights (and single smart plugs) work just fine.

@cjacunad, there are a couple GitHub issues open regarding this problem. If you want the issue to get more notice go here and here to comment on the issue submissions.

I’m now suffering this too. have added to the github comments

Done logging my thread, hope someone look at this.

I also freaking out evaluating flashing tuya switchs, the custom_component, but they are all too confusing, and some are now reported as not working anymore.

Hi I’ve had the same error as the one mentioned here. Also in combination with “connection pool is full”. So i’ve made a small PR at tuya to see if we can remedy this.

In there i’ve also included a max_retries configuration option. Now for this to work in home assistant there must be done some more plumbing, but i’ve cobbled up a dirty hack to get it running. See: GitHub - jzandbergen/home-assistant-tuyahack: Let's see if this works.... (openapi.py line 65 till 75).

You can build that docker(in my case podman) container yourself, or pull it from docker.io/goestin/homeassistant:tuyahack. USE AT YOUR OWN RISK :wink: