Tuya Device Help


#22

has anyone managed to get Tuya switch working yet?


#23
I just got it working. 
My first wall socket plug from [email protected]
But it does not update status when changed locally

Steps:
1) Install efamilycloud version 1.0.7 (found on google search - not the play store one)  
2) Setup adding the socket
3) Install the TuyaKey Grab from https://github.com/bobalob/TuyaKeyGrab
4) Get the key and id.
5) Config Hass as bellow:

platform: tuya
host: 192.168.1.172
local_key: xxxxxxxxxxxxxxxxx
device_id: xxxxxxxxxxxxxxxxxxx
switches:
  switch1:
    friendly_name: Tuya01
    id: 1

#24

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


#25

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!!!


#26

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

#27

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


#28

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


#29

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


#30

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


#31

Did that help anyone?


#32

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?


#33

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


#34

Dear Liz:

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

Thank you!

Harv


#35

I summarized the instruction in the following post:


#36

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


#37

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.


#38

Thanks, got rid of it


#39

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


#40

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.


#41

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