Tuya Device Help

Yes, that was a good idea: isolating the problem to just the one device. Here’s my switch:

My exact light is no longer available from AMZN in Germany - but here’s the same model:

I wonder if the Tuya protocol is compatible with OMOTON in the HA environment… have you tried any other platforms? Arduino for example?

Lastly, do you have Alexa by any chance? Am curious if she recognizes the OMOTON plug… if so - have you tried removing it from the Alexa app and then rebooting Hassio and seeing if it would discover the plug? BTW - what version of Hassio are you running?

Best regards, Liz

@liz_myers i know what the problem is now. i spoke to @huangyupeng at he confirmed my kind of plug(socket + light) is not yet supported. but it will be supported soon.

1 Like

@zhide.p,
Good job. I’m glad you got to the bottom of it. Thanks for letting me know. - Liz

Yeah @zhide.p hope your model and my door sensors get implemented very soon. Are your plugs workable through ifttt or anything other than the tuyasmart app?

if you ever installed a custom component of tuya.py, please remove it (see my post after Liz Myers)

Is the second part required, or is that instruction for the old Tuya integration? It isn’t documented

There are 2 apps. TuyaSmart and Smart Life. Both works for Tuya, but the same account can be used to login to both apps. I tried it with both apps, but still cannot pull the devices automatically.

I have also tried to add the switch manually to configuration, but it does not help.

How to get local_keys?
Please guide

There is an app for android call Tuya Key Grabber

https://github.com/bobalob/TuyaKeyGrab

Hi everybody,

i need a littel help on Tuya platform, i read what you entered below, but i still have issue on tuya platform

here my configuration.yaml

tuya:
username: ‘069019XXXX’
password: ‘aXeXER953’
country_code: ‘33’

switch:

  • platform: tuya
    host: 192.168.1.14
    device_id: 0220046668c63aaf583e
    local_key: aec3185bf0d58b90
    optimistic: true
    switches:
    switch1:
    friendly_name: Salon
    id: 1

Here the issue on the first page of Home Assitant:

Invalid config

The following components and platforms could not be set up:

  • tuya
  • switch.tuya

Please check your config.

And here the log of "error during setup of component tuya:

Sat Aug 18 2018 13:06:18 GMT-0400 (heure de Bolivie)

Error during setup of component tuya
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/urllib3/connection.py”, line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File “/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py”, line 56, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File “/usr/local/lib/python3.6/socket.py”, line 745, 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.6/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 849, in _validate_conn
conn.connect()
File “/usr/local/lib/python3.6/site-packages/urllib3/connection.py”, line 314, in connect
conn = self._new_conn()
File “/usr/local/lib/python3.6/site-packages/urllib3/connection.py”, line 180, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f31168cbd30>: 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.6/site-packages/requests/adapters.py”, line 445, in send
timeout=timeout
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py”, line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘px1.tuyaus.com’, port=443): Max retries exceeded with url: /homeassistant/auth.do (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7f31168cbd30>: 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.6/site-packages/homeassistant/setup.py”, line 148, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/tuya.py”, line 63, in setup
tuya.init(username, password, country_code)
File “/usr/local/lib/python3.6/site-packages/tuyapy/tuyaapi.py”, line 44, in init
self.get_access_token()
File “/usr/local/lib/python3.6/site-packages/tuyapy/tuyaapi.py”, line 58, in get_access_token
headers = headers
File “/usr/local/lib/python3.6/site-packages/requests/api.py”, line 112, in post
return request(‘post’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/api.py”, line 58, in request
return session.request(method=method, url=url, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 512, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 622, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/adapters.py”, line 513, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘px1.tuyaus.com’, port=443): Max retries exceeded with url: /homeassistant/auth.do (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7f31168cbd30>: Failed to establish a new connection: [Errno -3] Try again’,))

Can some one help me please ??

i am getting same error from last 2 days,
dont know if it is the issue with tuya component.

i get this error even i have corrrect informattion

my config:
Tuya/Arilux/Smartlife Components

tuya:
username: !secret tuya_username
password: !secret tuya_password
country_code: !secret tuya_country_code

2018-08-18 16:05:12 ERROR (MainThread) [homeassistant.setup] Error during setup of component tuya
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py”, line 148, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 331, in iter
yield self # This tells Task to wait for completion.
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 244, in _wakeup
future.result()
File “/usr/local/lib/python3.6/asyncio/futures.py”, line 244, in result
raise self._exception
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tuya.py”, line 63, in setup
tuya.init(username, password, country_code)
File “/srv/homeassistant/lib/python3.6/site-packages/tuyapy/tuyaapi.py”, line 44, in init
self.get_access_token()
File “/srv/homeassistant/lib/python3.6/site-packages/tuyapy/tuyaapi.py”, line 62, in get_access_token
raise TuyaAPIException(“get access token failed”)
tuyapy.tuyaapi.TuyaAPIException: get access token failed
2018-08-18 16:05:13 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.tuya. Setup failed for dependencies: tuya

go search my post at this thread.

I purchased 4 of these Smart Power Strips. They work fine in the SmartLife app and with IFTTT. I tried various ways of getting them working prior to HA v. 0.74.0 but nothing ever worked. I’ve upgraded to HA v. 0.77.3, now which should include the new Tuya component. Per a previous post in this thread, I cleaned up all the old stuff that I installed previously.

I added this to my config.yaml:

tuya:
  username: '[redacted]'
  password: '[redacted]'
  country_code: '1'

When I restarted, I got this message:

Invalid Config
The following components and platforms could not be setup:

  • tuya

Please check your config.

Per another post in this thread, I went to Tuya’s IoT site and tried to login. No joy. So I created a login (using the exact same login credentials I had used in the SmartLife app). I restarted and the Invalid Config error went away.

Because I’m using a multi-outlet power strip with 4 individually controllable sockets/switches (+ a group controlled bank of USB sockets), I tried to base my config.yaml entry on this post which appeared to be a similar switch/strip.

switch:
 - platform: tuya
   host: 10.88.7.193
   optimistic: true
   friendly_name: SmartStrip-BC
   id: 5
   switches:
     switch1:
       friendly_name: BC-USB
       id: 1
     switch2:
       friendly_name: Corner Lamp
       id: 2
     switch3:
       friendly_name: BC2
       id: 3
     switch4:
       friendly_name: BC3
       id: 4
     switch5:
       friendly_name: Home Theater Bluetooth
       id: 5

It does not work. I’m not getting any errors - but I’m not seeing any switches, either, and I can’t figure out why.

Are we sure about that? I don’t have the local_key or device_id so I certainly hope they aren’t necessary.

Are we sure about that? It seems counter-intuitive to me; it seems like HA would want to know the IP address of the Tuya device - not my Raspberry Pi (it can easily get its own IP address). In any case, I’ve tried it both ways, restarting HA in between, and neither way works. It would still be nice to get clarification on this so I can rule that out as being the problem.

HA did not discover any group or entities for me after restarting.
I also tried calling the tuya.force_update and tuya.pull_devices services - multiple times - if they do anything at all, I’m not seeing it.

I have a feeling I’m really close, here, but I can’t quite make it across the finish line.

I got some help from Yupeng at Tuya. All I had to do was change platform to “jinvoo_smart” (My devices are Jinvoo Smart devices - which makes perfect sense since the app I use to control things is the Jinvoo Smart app. No other configuration was required - after a restart, everything was discovered and works perfectly! This is all I needed in configuration.yaml:

tuya:
  username: 'me@my_email.com'
  password: 'my_secret_password'
  country_code: '1'
  platform: 'jinvoo_smart'

I deleted the entire “switch” section.

hi, i’ve a question.

i’ve successfully added two tuya compatible plugs into homeassistant with this component. but why i can’t read the energy consumption values? on the smart life app i can read it.

It’s an api problem? thanks

As a caveat for prospective buyers of NEO/COOLCAM window-door sensors (which operate with the TuyaSmart app) please be aware that they cannot be integrated with ifttt or google home as they advertise. Of course neither can they be discovered or operated thru this component in HA.

Has anyone been successful in using this component with tuya window/door sensors like this one.

Also, does this component work with tuya wifi power strips like this one that have more than one plug? The power strip states you can control each switch individually and you can also control the entire power strip at once (turn off all switches if you want).

I’d like confirmation on these two tuya products before I add them to my setup.

Dear all:

I thought I had this tuya thing figured out. Afterall, I did post a summary on how to solve this tuya power switch issue:

After I upgraded HomeAssistant from 0.74 to 0.77.3, my tuya no longer works.

Mind you that all i did was upgrade my HA by typing
hassctl hass-upgrade
and I didn’t touch any of my configuration file.

But now my tuya no longer works. The error message is as cryptic as ever:

tuyapy.tuyaapi.TuyaAPIException: Get accesstoken failed. Username or password error!

Here is the thing. I didn’t change the username nor password. I didn’t touch anything else. and I double checked my username/password combo with the smartlife app on android AND iOS and the username/password pair still works on the apps

What went wrong?

I believe somewhere between .74 and .77 you had to differentiate whether you registered with a tuya app or a smart life app with the following in your configuration.yaml:

tuya:
  username: !secret tuya_username
  password: !secret tuya_password
  country_code: 1
  platform: smart_life

where platform: is either tuya or smart_life (or some other marketer’s name)

1 Like

I propose that the entire tuya component be rewritten. See my comment here for the reason and for links to code that someone has created that allows for all devices to be controlled locally and without the cloud.