Discussion of local control of Tuya Smart Wifi devices without flashing firmware

Discussion of local control of Tuya Smart Wifi devices without flashing firmware

I decided to dive into this over the weekend. I am guessing some people out there have figured some of this out already on their own and maybe it is hiding in this forum somewhere.

I decided to try out a node-red implementation. There are a few out there but this one looked like it had the best documentation and was being maintained still:

Here is my Flow I have setup so far for a LED light strip which will keep the state of a virtual device in sync with the device bi-directionally. The On/Off is fairly easy. The info for the LED color/hue/sat/etc.. all seems to come in as a single hex string and I have not figured it out yet.

dps 20 is for on/off. dps 21 will be either colour or scene, and then dps 24 is the hex string which represents the color. This encoding look familiar to anyone? Color set here is Red full brightness (may not be perfect red color as the app has a wheel, but it looks close to it). Or is there any docs on there for this stuff from Tuya? Their developer site has tons of info, not sure what I am looking for exactly so its hard to find anything.



I also found this generic Hubitat driver that someone created which can be converted to work for any Tuya device. You would probably need to make a new driver for each type of device. He has two examples in his GitHub.


Tuya is now a member of the Zigbee Alliance (now called the Connectivity Standards Alliance). They are starting to introduce devices that are fully Zigbee 3.0 compliant. Such devices can be connected directly to Hubitat without use of the Tuya Smart Life app....if you can find a suitable driver.

Tuya even has a Zigbee 3.0 compliant bridge, but I do not know if it can be interfaced with Hubitat.

My only Tuya device at this time is a vibration sensor. Initially, I had it operating using the Konke Motion Sensor driver, but @kkossev modified the driver so that it is specific to the vibration sensor. The modified driver works well. It might be possible to modify the Konke driver to work with other Tuya devices, but I do not have other devices to test.

@rwclements228 sounds like your device might be Zigbee? I am talking about Wifi devices here, I guess I should clarify. Zigbee is always local (unless it also is using Wifi), so not really an issue I don't think. There are a LOT of Tuya wifi devices floating around out there, MANY inexpensive LED light strips seem to use Tuya.

1 Like

I realize there are Tuya WiFI devices. I try to avoid using WiFi devices unless there is no alternative available. I have a Hunter fan that uses their SimpleConnect WiFi app. I can control it using Alexa, but I do not have it connected to Hubitat. I know it can be done, but it is not worth the effort.

I hope you are successful with your project.

Same here but sometimes the price is worth it for me as long as I can connect it to Hubitat in some way. Also, gifts, or people may have old Wifi devices from before they started with Hubitat. I really dislike polling Wifi devices as well, but with the Tuya devices (both setup with cloud and local control) they push out updates which is very nice. No polling needed.

I also have some KASA devices which have to be polled locally, not too bad but you cannot get instant updates. I use them for lamps or holiday decorations which I can safely poll at 30 minutes because no one is turning them on manually. Besides that I also have one Govee LED strip which is very nice actually and supports BLE control via a mobile app. It has an open and documented cloud API. But again, the API needs to be polled to a cloud server, and it does not push out updates.


@mjruotolo requested a copy of my flow so here it is. Never really finished it all the way but it should work for on/off and the color. I think I am actually going to take a second look at the Hubitat driver I linked to above see how that might work with it.

I have just gotten into this as I wanted to bring my Costco/Feit/Tuya wifi light strips and color bulbs into HE for local control. I used the tinytuya tool to extract the keys and have successfully connected them using the generic driver @holand.ivar wrote (hubitatappndevice/Device/tuyaDevices at master · ivarho/hubitatappndevice · GitHub). I'm now looking to customize the driver to adjust color, brightness, etc. As a novice developer I just need to figure out how to pass the codes/capabilities to the end points. For example, here are the end points I have access to with my light strip:

20 Switch True/False
21 white/colour/scene/music
22 Brightness 10-1000
23 Color Temp 0-1000
24 Color hsv h:0-360,s:0-1000,v:0-1000
25 Scene (e.g. Halloween: 03323202001903e803e800000000323202012c03e803e800000000323202006e03e803e800000000)

Any guidance would be awesome!

I have a light strip with pretty much the same dps endpoints. I took a driver from another dev made for RGB bulbs and converted it. It seems to be working pretty good. It’s designed to sit as a component as part of his cloud integration, it works standalone but I had to copy some data over from the could device. I will see about posting it on a GitHub gist for an example.

@jonathanb has done some work on local support.

Yes that’s the one I used as my base.

Of course...after I posted was when I realized you started this way earlier this year.

@jtp10181 @FriedCheese2006 This is very helpful. I was able to pull in the devices and use the RGBW driver to control my wifi bulbs locally with the cloud fallback using @jonathanb's Tuya Cloud drivers. I'm getting closer! I'm also tweaking the RGBW driver to adjust the dps values. Now I need to have it send color in HSV instead of RGB. @jtp10181 if you happen to post your driver, I'd love to see it.

I have the tweaks in here to support DSP 20, 21 and 24. My strip does not have CT so that was not touched. You could use this as a drop in replacement driver or just pick pieces out if you want. It does either need to be used as a child of Johnathan's cloud driver, or if you use it standalone you have to copy some of the data values over using a third party app for it to work. I do have it fixed to send the HSV only instead of the RGB+HSV, along with a couple bug fixes I found and some other adjustments.

Need to click "RAW" on both the driver (TuyaLocalRgbLight.groovy) and library (TuyaProtocolLibrary.groovy) attached here:

If you go to revision tab, I posted the original driver then mine over top of it so you can see a diff: Revisions · TuyaLocalRgbLight.groovy · GitHub

1 Like

@jtp10181 Thanks for your post - very helpfull -

I managed to get my Device/Local key using the following scheme. Quite straightforward if we use the same Product version (not the latest ones)

So I then tried using your driver, and I got this error. Am I missing something ?



Yes I failed to mention you also need to install this library file. I made some further tweaks to the driver and also the library so that it would not have to recalculate the heartbeat string every time it sent it out.

I am currently using it as a driver on the child device created by the cloud integration and it works well, controlling locally most of the time but has the cloud as a backup.

EDIT: Updated post above with better links and updated the driver so be sure to grab the new version.

Thanks. Quick question - this is local tuya driver right ? if so, where do I set the Device / Local Key ?

It is designed to be used with the cloud integration, which creates the child devices and populates a bunch of data info. Then you change the driver on the child to this local driver to get dual control. The author of this integration has these drivers in his GitHub, I just tweaked them to work with my LED strip and did a few upgrades.

Here is the cloud integration: [BETA] Tuya Cloud Driver (Limited device support)

Here is what it looks like in the data:

You can also let it create the child devices, then copy the data to a new virtual device and use the local driver standalone. I tested this for a little bit and found it was not as reliable as having the dual setup.

This project sounds very exciting. I have a bunch of tuya wifi devices from the past.
Unfortunatelly i wasnt able to make the cloud api to work.
I would be very grateful if you could create an app that an average person could use too.
Happy Santa day. Merry Christmas and Happy holidays girls and guys !