[BETA] Tuya Cloud Driver (Limited device support)

Check the logs first to pinpoint where the failure may be.

Assuming you subscribed to the correct service API (device notification) in the Tuya server and you all have the credentials correct then check the app on your phone to verify which datacenter you are connected to. I'm in the Eastern US but needed to select the western US server.

Hope that helps.

Looks like the Tuya Cloud API has support for the first 4 effects (scene_1 through scene_4) so those can be implemented. You will notice 5-9 don't show up with a code so we can't send the command via the API -- this is a limitation that if the Tuya cloud API doesn't support all the features of the device there is no way to send it until they do.

1 Like

Maybe I found the answer in the logs. I found a warning saying that the token is expired. Now the question is how to fix that…

Tuya was messing with their server a few days ago. Read above a little, if everything looks correctly setup then you may need to change your password.

1 Like

I seem to have spoken too quick. At first, all devices worked perfect, shortly after my Smart Life SS01S and 3 way switchesSwitches stopped responding. However, my Smart Mini Plug_SK50 work perfect. Any ideas? I am an amateur at this, so please forgive me if I am missing something basic.

No idea sadly

The first thing to do is review the logs to see where/when the failure occurs. You'd be hunting in the dark right now.

Thank you!!, I'll try to figure out the logs... Thank you for your responses

Hi Jonathan,

Do you think we can remove the 'light' functionality on the ceiling fans, please?

I didn't catch this in my testing but there's an annoying downstream issue when I say "Alexa, turn of 'X' room". If 'X' room has one of the ceiling fans (5 rooms), Alexa is trying to turn off the fan speed and the switch that we repurposed as the light. When this happens, she will throw an error and say "I'm not sure what went wrong". It took me a while to figure out it was all the rooms with fans that were part of the same room in Alexa that is causing the issue.

If we can undo whatever we did to make the light part work, I think that will solve the error. I never use the ceiling fan lights so doing without the functionality until we can get a suitable solution is not a pressing issue to me. I'd much rather stop the annoying feedback from Alexa😄

You should be able to just go into each device and change the driver back to the "Generic Component Fan Control" from Hubitat which does not include the light control however I this might not solve the problem which if so, I have another way to help. I also have a new re-written driver that will allow separate light and fan devices nearly ready for testing.

1 Like

Yes, I forgot that we changed that driver; thank you for the reminder. I switched it back and as you predicted, it didn't solve the problem (and I understand why). Alexa still throws the "im not quite sure what went wrong".

I can hang tight and just live with the error until the solution is complete. Its not like by voice is the primary way I turn off rooms :grinning:


I'm having an issue creating my Tuya developer project.. has anyone else had the tuya site fail when clicking on the Devices tab? I get a 'too many redirects' error every time (I tried Chrome and Safari).

Anyway, I'm guessing this step is necessary as I did try creating the new virtual device in Hubitat but get this error in the logs:

dev:7312021-11-18 08:15:41.005 pm warnTuya cloud request failed: {"code":2406,"msg":"skill id invalid","success":false,"t":1637284536228}

Guess this was just a tuya server error as I tried again this morning and it worked great!

I was able to get the driver installed and it found the 2 Tuya branded wifi plugs I have and created Hubitat devices for each.

Next, I tried to turn on 1 of the plugs and got the result below. Is there something I can try to help debug?

dev:7312021-11-20 09:31:14.999 am warnTuya cloud request failed: {"code":1104,"msg":"type is incorrect","success":false,"t":1637418673870}
dev:7312021-11-20 09:31:14.311 am debugTuya API POST [uri:https://openapi.tuyaus.com, path:/v1.0/devices/0220049068c63aad61d2/commands, query:null, contentType:application/json, headers:[t:1637418674309, client_id:7ssh3mjgb3qixla77woj, Signature-Headers:client_id, sign:3FC14066A727BE7CC61E32D9E1CE71B497EDC8E41DD60BBC3B31C94FEA664B64, sign_method:HMAC-SHA256, access_token:<SNIP>, lang:en], body:{"commands":[{"code":"countdown_1","value":true}]}, timeout:5]
dev:7312021-11-20 09:31:14.307 am debugTuya device 0220049068c63aad61d2 command [[code:countdown_1, value:true]]
dev:7312021-11-20 09:31:14.305 am infoTurning Porch Lights on

edit: I should also note that turning the light on/off via the SmartLife app updates the Hubitat device state instantly

dev:7332021-11-20 09:44:45.167 am infoswitch is on
dev:7312021-11-20 09:44:45.165 am debugTuya Porch Lights sending events [[name:switch, value:on, descriptionText:switch is on], [name:countdown_1, value:0, descriptionText:Porch Lights countdown_1 is 0 , unit:]]

@jpage4500 I've made an update that should solve that problem, give it a try now.


I just updated the driver code but when trying to save I get this error message:

The current scope already contains a variable of the name code @ line 225, column 12.

Remove line 224, I'll fix the typo in Github when Github returns from some downtime.

great - that worked and I can control the outlet too! thanks!

I followed the instructions and was having difficulity getting the driver to sign in.

I looked into the code and discovered that settings.countryCode in line 1268 was null - I changed this to state.countryCode and done the same on line 1273 and then the driver was able to get a token.

Next issue that has me stumped is that I'm getting the error -> No permissions. This API is not subscribed. Log reproduced below.

Anyone got any ideas? This hub is on
Update - I hit "Refresh" and the driver found my 4 devices !!!!!

3 of my devices are Heaters - the driver references "Generic Component Heating Device" - Hubitat does not have such as driver - at least my hub don't have one - any ideas for an alternative driver?

My Dehumidifier was created as a Generic Component Switch - as described in an earlier contribution.

dev:15932021-11-28 23:14:09.609 warnTuya Virtual Device cloud API request failed: {"code":28841101,"msg":"No permissions. This API is not subscribed.","success":false,"t":1638141249369}

dev:15932021-11-28 23:14:09.238 debugTuya Virtual Device API POST [uri:https://openapi.tuyaeu.com, path:/v1.0/iot-03/open-hub/access-config, query:null, contentType:application/json, headers:[t:1638141249232, client_id:cqs9swyxb4pmmxx7cky1, Signature-Headers:client_id, sign:51D1BF496555201D48B507750AABDE125A8B1B35472555279F10B2120282F52C, sign_method:HMAC-SHA256, access_token:f5352e44ccdb9aee046126b72af994bb, lang:en], body:{"uid":"eu1612124555516Ii4B7","link_id":"77c1c943-a66b-4922-9d44-9abc8f416137","link_type":"mqtt","topics":"device","msg_encrypted_version":"1.0"}, timeout:20]

dev:15932021-11-28 23:14:09.232 infoTuya Virtual Device requesting Tuya MQTT configuration

dev:15932021-11-28 23:14:09.187 infoTuya Virtual Device received Tuya access token (valid for 7200s)

dev:15932021-11-28 23:14:09.183 debugTuya Virtual Device API response [result:[access_token:f5352e44ccdb9aee046126b72af994bb, expire_time:7200, platform_url:https://openapi.tuyaeu.com,

You'll find additional generic component drivers available here and I've updated the code with your fixes for countryCode too.