Tuya integration

Hello all!
Im just wondering if there is any integration with Tuya app? I know its Wifi based but want to ask before i buy ST hub and selling my hubitat hub.

Three things.

  1. Welcome to hubitat.
  2. There is a search magnifying glass in the top right corner where you can search for stuff
  3. If you reload the FW with Tasmota install the following you get local control without any cloud dependency

Thanks for the help :heart_eyes:

1 Like

You can also look here if you need direct control of the tuya WIFI devices from Hubitat:

Getting the client secret etc, is a bit cumbersome however. But there are a few guides on this online. I have a Neo Wifi Siren that works very stable with my driver.


Looking at your readme on the Github, you said you had Linux tools to extract the device key. Can you tell me what they were so I can try on my end?

I used the tutorial found here: tuyapi/SETUP.md at master · codetheweb/tuyapi · GitHub, and I used what is described under: Listing Tuya devices from the Tuya Smart or Smart Life apps (highly recommended)

It is unfortunately a bit cumbersome this approach, but the moment you have the device secret you are good to go.

The best solution would have been to be able to pair these devices directly to Hubitat of course.

For the Device endpoint, did you use Wireshark? I am trying to determine that part, I managed to get the device secret of one of my bulbs finally. Or did you use a packet capture on your phone?

I tried to use Wireshark, but then I found that there is an app on Android called Packet Capture. This app is capable of isolating data traffic from selected apps, hence it was perfect for the job.

However, you are not able to sniff the device secret with a phone app. I assume that the device secret is something that is exchanged during device paring, and it seems that the Tuya app is smart enough to understand that it is being sniffed during pairing. Perhaps more advanced sniffing methods can be used...?

What the app gives you is the device ID and the status of, and any endpoints, on the device (this is sent in clear text). The device ID can then be used towards the tuya web development platform with the mentioned Linux tools to extract the device secret.

This is a screen shot of what I get when I capture the traffic from a tuya smart app called "Jinvoo Smart" (same as Smart Life, just re-branded).

What you see here is the Jinvoo app asking my siren for status, where the siren answers that dps: 104, which is the endpoint, is false, i.e. off. Then the app sends a message about turning on the siren, this can only by done encrypted with the device secret. If you decrypt this message you'll see that it sets dps: {"104", true}.
Lastly the device sends some confirmation and status back to the app. From what I can see it does all of this locally on the network.

You can try Charles. I've used it for Sonoff iFan02 and it worked fine.

Were you successful in getting your Tuya device connected to HE‽ I'm thinking to add my diffuser but seems to be a lot of work?

Anyone have success here? I'm trying to my Tuya blinds which I using via Tuya cloud to work with HE. I have my IP address for the device. I don't know how to get the end point value. I don't see anything on iot.tuya.com to help.

I have updated my tuya integration to support devices using version 3.3 of the tuya protocol. I have tested this integration towards several tuya units and it seems very solid.

I have also added more documentation on how to use is here, and thanks to the python tinytuya project it has become much simpler to get the device secret key. I am thinking of creating an instruction video as well on how to set this up.


I'm using two Tuya devices. One is a dual outlet smart plug (HBN U153T) connected to the Tuya mobile app and one is a dual outlet plug with USB ports (JINTU BSD08) connected to the Smart Life mobile app.

I was able to follow all of the instructions and get the local ID.

I'm confused by the Endpoint parameter. Does it take the entire JSON string or just part of it?

An example:
Status: {u'11' : 0, u'10' : 0, u'38' : u'memory', u'44' : u'', u'42' : u'', u'43' : u'', u'40' : u'relay', u'41' : False, u'1' : False, u'3' : False, u'2' : False, u'9' : 0}

If you are using my tuyaGenericDevice the endpoint parameter is a number 0-99999... that is a true/false endpoint, so that when you click On() you send a message containing {endpoint_number: True} and Off(): {endpoint_number: False}. For any other types of endpoints you have to go into the driver and add/modify for whatever you need. Please see my tuyaWifiSiren as an example.

Based on the status message in your comment:

Status: {u'11' : 0, u'10' : 0, u'38' : u'memory', u'44' : u'', u'42' : u'', u'43' : u'', u'40' : u'relay', u'41' : False, u'1' : False, u'3' : False, u'2' : False, u'9' : 0}

Possible endpoints to control with On()/Off() (True/False) is 41, 1, 3, and 2. What they control you have to just experiment your way to. I will assume one of the endpoints 41, 1, 2, or 2 will control the actual output of the smartplug.

If you look to my tuyaWifiSiren example you see that the siren gives a status message as follows:

Status: {'101': '4', '102': '3', '103': 15, '104': False}

To control the siren sound type I write to a string based endpoint that I have found to be 102 in the following way:

def buf = generate_payload("set", ["102":type.toString()])

The "set" is the "change something on the device" command, and the ["102":type.toString()] contains the JSON message.

I just wanted to say thank you for this driver. I was, so far, able to get my Graywind shades and panel blinds working. This sure beats trying to flash firmware or relying on cloud integration!


@kbrabble Are you able to share information about what changes you had to add to be able to controll your Graywind shades? I have Graywind curtains and I have all of the relevant device info but don't understand how to determine what device endpoint I need to be able to control opening and closing and how to actually send the command. Any help you can provide would be greatly appreciated. Thanks

I just made a couple of quick and dirty modifications to holand.ivar's generic driver. I don't know anything about creating drivers, but the mods I managed allow me to input the proper information to connect to the blind and open/close or set it to a %. Probably not the best way to accomplish this, but it works. There are a couple of google drive links to text files with the modified driver code below. Hope this helps.

For Graywinds Roller Blinds:

For Graywinds Panel Blinds:

Thanks for the quick response. I'll look at the code and see if it will work for my curtains and what changes may be needed. Thanks for the help with this and a big thanks to @holand.ivar for this effort. Great work!!!

1 Like

I was able to make some minor edits and get it to work for my curtains. @holand.ivar do you happen to know how I can change the Command button names in Hubitat to Close and Open instead of On and Off? This driver is excellent and now allows local control of my wifi Tuya devices. Thank you for the effort, I've tried to learn simple things by following your code. Maybe someday I will be able to write my own driver....in 100 years :thinking:

In the metadata section you could either add the windowBlind or windowShade capability (may also give you other commands you dont want to deal with).
capability "WindowBlind"

Or manually add two new commands, open and close

command "open"
command "close"

Then down in the code just above the on/off functions, add open/close functions that simply call the appropriate on/off functions.


def open() { on() }
def close() { open() }