Tuya Device Help

Do you get status update when manual change switch status?
I get updates almost 1 minutes after changing…

Today It stopped working…
And I got a message from Google Play Store telling the EFamilyCloud was updated to the last version…

I can not say that was the cause, but now I installed again the 1.0.7, got another key and it is working again. Blocked Play Store updates for that app and lets see what happen!!!

I followed your instruction and instruction on sean6541’s github page

it didn’t work. the trace back is as follows

2018-07-09 00:00:00 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall switch.turn_on: entity_id=['switch.hlight']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1021, in _event_to_service_call
    await service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/__init__.py", line 109, in async_handle_switch_service
    await switch.async_turn_on()
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/switch/tuya.py", line 132, in turn_on
    self._device.set_status(True, self._switchid)
  File "/home/homeassistant/.homeassistant/custom_components/switch/tuya.py", line 96, in set_status
    return self._device.set_status(state, switchid)
  File "/srv/homeassistant/lib/python3.5/site-packages/pytuya/__init__.py", line 294, in set_status
    data = self._send_receive(payload)
  File "/srv/homeassistant/lib/python3.5/site-packages/pytuya/__init__.py", line 167, in _send_receive
    data = s.recv(1024)
socket.timeout: timed out

Try this mate, I have tuya sockets and wrote a mini guide. Happy to help where I can

would you give us a pointer on where is your mini guide?

i just presume u managed to get tuya to work, hence, wrote the mini guide.

thanks

would be useful if I added the link wouldn’t it! :see_no_evil:

For info

activate developer tools on android phone and open
enable usb logging
install adb on your laptop
navigate to folder where you installed adb on cmd line
Run adb logcat > logcat.txt
start the app mentioned by @fastrax https://github.com/clach04/python-tuya/wiki/bin/Jinvoo%20Smart%201.0.3.apk 1
ensure devices are removed and re add your device whilst adb logcat is running
checkout logcat.txt
remove all apps

1 Like

Did that help anyone?

I followed your link, and mimic your setup.

My configuration is as followed:

  • platform: tuya
    host: 192.168.31.223
    name: harveyLight
    device_id: XXXXX
    local_key: YYY
    id: 1

The configuration seems to be legit.

However, when I tried to turn on the light, i still got an error:

2018-07-18 18:50:48 ERROR (MainThread) [homeassistant.core] Error executing service <ServiceCall switch.turn_on: entity_id=['switch.harveylight']>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1021, in _event_to_service_call
    await service_handler.func(service_call)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/__init__.py", line 109, in async_handle_switch_service
    await switch.async_turn_on()
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/switch/tuya.py", line 132, in turn_on
    self._device.set_status(True, self._switchid)
  File "/home/homeassistant/.homeassistant/custom_components/switch/tuya.py", line 96, in set_status
    return self._device.set_status(state, switchid)
  File "/srv/homeassistant/lib/python3.5/site-packages/pytuya/__init__.py", line 294, in set_status
    data = self._send_receive(payload)
  File "/srv/homeassistant/lib/python3.5/site-packages/pytuya/__init__.py", line 167, in _send_receive
    data = s.recv(1024)
socket.timeout: timed out

Any idea where is my problem?

SOLVED: Tuya Light and Switch Both Working

HA v. 0.74.0
Mac OSX w/HASSIO

Setup Config.yaml as follows:

1. Enable Tuya Platform: (pls note: all values are strings)

tuya:
  username: 1234567890'      // this is my 10 digit mobile no starting w/area code
  password: 'your password'  // this is my password for IoT account on Tuya site
  country_code: '1'          // this is for US. change to match your country

2. Setup Entities (devices) in config.yaml:

group
  Tuya_Devices:
    name: Tuya Devices
    entities:
      - switch.000000000000000000   //ha discovered this for me after step 1 restart
      - light.00000000000000000000  //and this too
      
light:
  - platform: tuya
    host: 192.168.X.XX
    local_key: 
    device_id: 
    friendly_name: Tuya Light
    optimistic: true
    id: 2
    
switch:
  - platform: tuya
    host: 192.168.X.XX
    local_key: 
    device_id: 
    friendly_name: Tuya Switch
    optimistic: true 
    id: 1

3. Discover some devices automatically
discovery: //this may help discover devices, was always toward the top of config file in my case

Hope that helps - Liz

1 Like

Dear Liz:

you just saved my LIFE!!! I struggled with this for MONTHS, literally!

Thank you!

Harv

I summarized the instruction in the following post:

How do we remove those components? Just delete the .py files?

yes.

The location the file is typically in your homeAssistant home directory’s

$homeassistant/custom_components/switch

subdirectory.

In my own case, (hassbian), the file is located at

/home/homeassistant/.homeassistant/custom_components/switch/tuya.py

and all you have to do is delete/rename the file, and in my case, I also remove the py_cache directory just in case since I have no idea how python cache its own compiled binaries.

Thanks, got rid of it

1 Like

This had driven me crazy for so long. Some said it worked and I followed their exact instructions and nothing.

Now, after deleting the old tuya.py files, it works!

Thank you all

1 Like

I can’t seem to get my account linked. I keep getting errors upon restarting referencing an invalid config on the Tuya component even when I’m just adding the login information (Though the configuration validator says it’s good). I’m using my normal Tuya login, though I’ve seen some people reference using the IoT platform log in. Do I need to make an IoT account then transfer my devices to that?

Thanks in advance.

show us your configuration file’s tuya / switch segments, as well as error messages.

Here’s what I have. Did you have to use a Tuya IoT account to make it work?

tuya:
  username: !secret tuya_user
  password: !secret tuya_pass
  country_code: 1

switch:
  platform: tuya
  host: 192.168.2.231
  local_key: [REDACTED]
  device_id: [REDACTED]
  optimistic: true
  switches:
    switch1:
      friendly_name: Printer Camera
      id: 1
    switch2:
      friendly_name: Printer
      id: 2
    switch3:
      friendly_name: Extractor Fan
      id: 3
    switch4:
      friendly_name: Switch1
      id: 4
    switch5:
      friendly_name: Switch2
      id: 5

EDIT:

Also, the error is not present in the system log. Just a large panel on the home screen stating:

Invalid config
The following components and platforms could not be set up:

  • tuya
  • switch.tuya

Please check your config.

> switch:
>   platform: tuya

Try the following (please pay attention to every single characters)

switch:
- platform: tuya

(notice that “dash” symbol)

Also, unless your tuya switch has multiple outlets, you should be doing the following IF you happened to have mulitple tuya switches:

switch: 
  - platform: tuya
    friendly_name: switchA
    id: 1
    ....
  - platform: tuya
    friendly_name: switchB
    id: 1
    ...
  - platform: tuya
    friendly_name: switchC
    id: 1
    ....

I have NO idea what those “id: 1” is for. I think someone here in the forum managed to get tuya to work without it. Since my tuya works right now, I am not going to touch anything unless it’s absolutely necessary :slight_smile: