[BETA] Tuya Cloud Driver (Limited device support)

Could you let me know if it freeze your hub, cuz with my 27 device hub was freezing 2 or 3 times a day?

Love your work @jonathanb , I've been wanting to run my Tuya Blinds via HE for a very long time - All I need now is a Blind driver. Any chance you could please make one using the Tasmota drivers as the basis?

PS, there's a stack of info over here too:

EDIT: NVM, I found your link to generic drivers which I'll test shortly:

Yup. I had to hook a smart plug up to it so I could reboot, about every 12 hours or so. Havn't had time to mess with it and see it's overloaded or what. Anybody know if there is a item limit in hubitat?

Update: These worked great! I finally have my blinds in HE! :sunglasses:

I was using the app "Rebooter" and I was rebooting the hub every 12 hours, but sometimes it wasn't enough.

So I disable the tuya driver and created virtual device that I synced with Amazon Echo.

My other Plan would be to transfer everything to a C-7 and only run tuya on my C-5.

@deanveatch and @Luft, there are other integrations such as Hue and Lifx which I am sure someone out there has lots of devices and I have not heard of issues with those. There might some efficiencies to be gained in this driver code. Check the logs > Device Stats and see what it is showing in there. I only have one device but the ms, Avg is high on the integration driver compared to other "devices".

I also have started to mess with local control on my device, so far I am able to sync on/off state but it is using Node-Red. If it gains interest I was thinking about checking into the generic local control driver that someone else posted (it needs to be tweaked for each type of device).

The average ms will never be as low as unencrypted communication. I also have my own drivers for Tasmota local devices and the overhead there is so much lower. Right now I show average of 46ms for Tasmota and 648ms for Tuya!

For each received MQTT packet from Tuya, it needs to be converted from Base64, then decrypted using AES/ECB/PKCS5Padding then JSON parsed and only then can the contents be parsed to trigger events.

You would think that since commands are sent to Tuya over HTTPS they are already secure but no, Tuya wants each command to also have an HMAC-SHA256 signature calculated for it (to avoid I suppose a man-in-the-middle attack?)

I've no idea how well Hubitat hardware is designed for AES instruction optimizations but all that overhead for each packet sent and received from the Tuya cloud adds up I would assume.

Any optimizations to the code would be helpful! :slight_smile: The send code is located in the source code at line 1890 to 1972 (tuyaRequestAsync). The parsing (parse) is located at line 655 (in my dev branch). The other area of optimization would be the createEvents method around line 1238 where the Tuya packets are converted to Hubitat events. Any experienced Groovy devs are very welcome to make suggestions for improvements.

Yeah that makes sense why it takes longer to process the commands compared to other integrations. The local control I am looking into does not require Tasmota flashing, there is local Tuya control but I cannot find very good docs about it.

Not sure if this is normal or contributing to the problem? I have not looked at the code yet to see why this happens, maybe it is just something with my device. But every time it refreshes I get multiple repeating log entries, I believe it is 6 every time. So if you have 25 devices and its doing some sort of processing x6 that would add up quick.

Yes that does look abnormal, I don't see that with my lights so I'd need to get a little more debugging detail to see the messages being received that is causing this behavior. Should only see one of those not six.

Check this post above for some debugging: [BETA] Tuya Cloud Driver (Limited device support) - #148 by jtp10181

And here is current with ONE refresh (I left out the API calls at the bottom and blacked out some private looking stuff). Even going two screens tall it was too much to get in one shot, it keeps going off the top.

Thank you, took a while but I tracked down the issue which was introduced when I added support for multiple child devices per tuya device. I've posted a fix in the latest development branch code if you would like to try it.


Looks like that did the trick for the repeating events. Still does not do anything with the brightness/level but I mostly just use it for on/off anyway.

I see you have some local non-Tasmota Tuya drivers in there also. Might have to check out the RGB one and see how it works on my light strip. Or at least it might help me decode the dps "colour" string for Node-Red.

I just fixed what I think was causing the brightness level issue. As for scenes, I've not yet seen a way to set a scene number in the API otherwise I could add that.

Still not working for the level. If you dont have any devices that support it, I will try and check it out since I can test various things until it works. Also trying to use setLevel command from the device generated this error:

I'm going to try removing all the tuya devices and just use the Tap to run automations. I can get by with that. Otherwise i'll have my IT brother in law take a look. i suspect i might be having issues with static vs dynamic ip adresses.

Ah, that was helpful, turns out yet another device with a different value. That now makes the supported functions to now be: 'bright', 'bright_value', 'bright_value_v2', 'bright_value_1' :laughing: Lets see if that gets us closer!

1 Like

This driver works for the fan / light module. Thanks allot, great work!

Hi @jonathanb can you help me with the Neo Zigbee Siren.

This is what i got from my tuya.

alarm_volume Enum
"range": [
alarm_time Integer
"unit": "s",
"min": 0,
"max": 1800,
"scale": 0,
"step": 10
alarm_switch Boolean

Thank you

This is just what I needed. Now I can delete another app from multiple devices. Thank you for your hard work!

1 Like

I think to enable the siren as a switch should (ha!) be simple, please try the development driver at https://raw.githubusercontent.com/bradsjm/hubitat-drivers/development/Tuya/TuyaOpenCloudAPI.groovy and see if the switch will activate the siren.