[BETA] Tuya Cloud Driver (Limited device support)

Finally got enough time to try this. I have three Mercator Ikuu fans (fan + light) and they show up fine, but I get these errors (and maybe others):

dev:2112024-02-07 19:23:51.170errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '100' with class 'java.lang.String' to class 'int' on line 1492 (method tuyaGetDeviceSpecificationsResponse)
dev:2112024-02-07 19:23:51.166errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '100' with class 'java.lang.String' to class 'int' on line 1492 (method tuyaGetDeviceSpecificationsResponse)
dev:2112024-02-07 19:23:51.166errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '100' with class 'java.lang.String' to class 'int' on line 1492 (method tuyaGetDeviceSpecificationsResponse)

I don't know groovy enough to know how to check type and cast from the string containing "100" to an int.

Code is latest installable, says at the end of the comments:

 *  01/24/23 - 0.3.7 - Support fan_speed_percent level

Ooh... control works, status doesn't, which would match the errors above - and not being able to convert string values ints

Edit 2: When trying the light half of the child device, I get a similar error but for a different part of the code - also not surprising:

dev:2112024-02-07 19:40:55.604errororg.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '100' with class 'java.lang.String' to class 'int' on line 653 (method componentSetLevel)

I am a new Hubitat user and just found out about this SmartLife cloud driver. I followed the installation instructions and was able to link 20 of my smartLife devices but not any more. All 0f my 36 devices shows in Tuya IoT dev platform but when adding the driver in Hubitat only 20 devices get added without any displayed errors. Is there any limits on the number of devices that can be added from Tuya? or this is a parm i can set to increase the limit from 20? thanks in advance.

Hi @tonyshor ,

Welcome to the Hubitat community forum!

There is no limitation on the number of Tuya devices processed in this driver. I am not aware of a limit imposed by Tuya as well.

What types of devices are not imported from the cloud account?
Are all your 36 devices WiFi only ?

thanks for your quick reply Krassimir. All 36 of my devices are Wifi and some of the NOT linked ones are identical to some of the linked ones but just happened to be over the 20 limit. I have 4 RGBW bulbs and 3 were connected but not the 4 one. I did some testing by deleting one of the first 20 devices from SmartLife and relinked and now i see the would had been the 21st device linked. it seems to be a limit imposed somehow. Again from the Tuya IoT dev platform all devices are seen so the issue is when adding the driver to Hubitat and creating the sub devices. It might be something trivial like setting max space or count limit by the driver. I hope someone in the group have seen this. Anybody successfully added the SmartLife/Tuya Cloud driver with more than 20 devices successfully? thanks for sharing your experience with me.

here is screen shot from Tuya IoT dev platform

and how it looks from Habitat

you see devices LivingRoomExt1 and LivingRoomExt2 linked but not
LivingRoomExt3 and LivingRoomExt4 (all 4 are identical devices)

Have you tried creating a second virtual device with the same driver? With some finessing, you can probably get the remaining devices added that way.

Yes JB10 i did, adding a second virtual device with the same driver link the same 20 devices.

These are the limits imposed by Tuya that I have found :

https://support.tuya.com/en/help/_detail/K9d1qhaytv1vq

Looks like when the API gets query, there is a limit of 20 device IDs that come back (Query Device Details in Bulk-Cloud Services API Reference-Tuya Developer) which is probably the problem that @tonyshor is having.

Based on this, if I had to guess, the only solution is to split the devices between the two apps (Tuya and Smart Life), create two different IOT projects, and have two different virtual drivers hitting each respective app. Going this route would mean that this integration has a theoretical limit of 40 total devices.

1 Like

Thanks JB10. You would not believe what happened since yesterday, When I looked at my Hubitat devices this morning, i found out 12 more devices were linked from the IOT project without me doing anything. Here is screen shot of the Tuya Cloud driver

you could see the device count is still 20 but the component devices shows 32 devices. i still have 4 more missing devices but it is looking much better now.

2 Likes

Hi @user6165

I have the same error and I would like to contribute to the driver. Was wondering if you found any work around before I dive in?

Thanks.
P

Hi Patrice. I ended up buying a BroadLink blaster which has a solid driver available.

Good luck!
Tim

Nice, sounds like a good solution. Thanks for pointing it out, I think I will end up doing the same. Cheers!

I can recommend the Broadlink remotes as well. I’ve been using 3 of these for probably 4 years now, they work remarkably stable!

1 Like

Hi @jonathanb i hope you can help, i had this working perfectly for at least 6 months. Howewer i've had all sorts of internet issues recently which caused my WIFI lights to go offline. I've since re-connected my 3 of my lights and they work fine via the Tuya app, however not via hubitat. I've tried all sorts of things and i've since created a new Project in the Tuya IOT platform, I've also deleted my old Virtual Tuya IOT cloud device in Hubitat and re-added a new one. The Hubitat Device appears to be able to see my Tuya devices as below. However the childs don't appear to work. I've noticed when i hit initialise, then it displays an error in the current states however when i hit refresh it displays the correct device count (3) and says ready. I've also transferred my new client ID and client secret.

I've added a screenshot of one of my child devices logs with the errors.

Any help would be appreciated as i'm pulling my hair out here :slight_smile:

image

image

2024-03-18 22:54:38.648debugFront Light 4 status [code:do_not_disturb, value:false]

dev:16512024-03-18 22:54:38.645debugFront Light 4 status [code:control_data, value:]

dev:16512024-03-18 22:54:38.643debugFront Light 4 status [code:countdown_1, value:0]

dev:16512024-03-18 22:54:38.639debugFront Light 4 status [code:scene_data_v2, value:{"scene_num":1,"scene_units":[{"bright":0,"h":90,"s":1000,"temperature":0,"unit_change_mode":"jump","unit_gradient_duration":90,"unit_switch_duration":90,"v":1000},{"bright":0,"h":10,"s":1000,"temperature":0,"unit_change_mode":"jump","unit_gradient_duration":90,"unit_switch_duration":90,"v":1000}]}]

dev:16512024-03-18 22:54:38.636infoFront Light 4 color is h:0 s:100 (Red)

dev:16512024-03-18 22:54:38.632debugFront Light 2 status [code:do_not_disturb, value:true]

dev:16512024-03-18 22:54:38.630debugFront Light 2 status [code:control_data, value:]

dev:16512024-03-18 22:54:38.627debugFront Light 2 status [code:countdown_1, value:0]

dev:16512024-03-18 22:54:38.627debugFront Light 1 status [code:do_not_disturb, value:true]

dev:16512024-03-18 22:54:38.625debugFront Light 1 status [code:control_data, value:]

dev:16512024-03-18 22:54:38.625debugFront Light 4 status [code:colour_data_v2, value:{"h":0,"s":1000,"v":1000}]

dev:16512024-03-18 22:54:38.624infoFront Light 4 color temperature is 6497K

dev:16512024-03-18 22:54:38.623debugFront Light 1 status [code:countdown_1, value:0]

dev:16512024-03-18 22:54:38.621debugFront Light 2 status [code:scene_data_v2, value:{"scene_num":1,"scene_units":[{"bright":200,"h":0,"s":0,"temperature":0,"unit_change_mode":"static","unit_gradient_duration":13,"unit_switch_duration":14,"v":0}]}]

dev:16512024-03-18 22:54:38.621debugFront Light 1 status [code:scene_data_v2, value:{"scene_num":1,"scene_units":[{"bright":200,"h":0,"s":0,"temperature":0,"unit_change_mode":"static","unit_gradient_duration":13,"unit_switch_duration":14,"v":0}]}]

dev:16512024-03-18 22:54:38.620infoFront Light 1 color is h:97 s:100 (Red)

dev:16512024-03-18 22:54:38.620debugFront Light 4 status [code:temp_value_v2, value:996]

dev:16512024-03-18 22:54:38.620infoFront Light 2 color is h:97 s:100 (Red)

dev:16512024-03-18 22:54:38.618infoFront Light 4 level is 100%

dev:16512024-03-18 22:54:38.617debugFront Light 4 status [code:bright_value_v2, value:1000]

dev:16512024-03-18 22:54:38.615infoFront Light 4 color mode is CT

dev:16512024-03-18 22:54:38.614debugFront Light 4 status [code:work_mode, value:white]

dev:16512024-03-18 22:54:38.612infoFront Light 4 switch is off

dev:16512024-03-18 22:54:38.611debugFront Light 4 status [code:switch_led, value:false]

dev:16512024-03-18 22:54:38.610debugFront Light 4 workMode white

dev:16512024-03-18 22:54:38.602debugFront Light 2 status [code:colour_data_v2, value:{"h":351,"s":1000,"v":1000}]

dev:16512024-03-18 22:54:38.597debugFront Light 1 status [code:colour_data_v2, value:{"h":351,"s":1000,"v":1000}]

dev:16512024-03-18 22:54:38.601infoFront Light 2 color temperature is 6535K

dev:16512024-03-18 22:54:38.598debugGroups: [Front Light 4:[[code:switch_led, value:false], [code:work_mode, value:white], [code:bright_value_v2, value:1000], [code:temp_value_v2, value:996], [code:colour_data_v2, value:{"h":0,"s":1000,"v":1000}], [code:scene_data_v2, value:{"scene_num":1,"scene_units":[{"bright":0,"h":90,"s":1000,"temperature":0,"unit_change_mode":"jump","unit_gradient_duration":90,"unit_switch_duration":90,"v":1000},{"bright":0,"h":10,"s":1000,"temperature":0,"unit_change_mode":"jump","unit_gradient_duration":90,"unit_switch_duration":90,"v":1000}]}], [code:countdown_1, value:0], [code:control_data, value:], [code:do_not_disturb, value:false]]]

dev:16512024-03-18 22:54:38.598debugFront Light 2 status [code:temp_value_v2, value:1000]

dev:16512024-03-18 22:54:38.597infoFront Light 2 level is 100%

dev:16512024-03-18 22:54:38.596infoFront Light 1 color temperature is 6535K

dev:16512024-03-18 22:54:38.595debugFront Light 2 status [code:bright_value_v2, value:1000]

dev:16512024-03-18 22:54:38.594infoFront Light 2 color mode is CT

dev:16512024-03-18 22:54:38.594debugFront Light 1 status [code:temp_value_v2, value:1000]

dev:16512024-03-18 22:54:38.592debugFront Light 2 status [code:work_mode, value:white]

dev:16512024-03-18 22:54:38.591infoFront Light 2 switch is off

dev:16512024-03-18 22:54:38.589debugFront Light 2 status [code:switch_led, value:false]

dev:16512024-03-18 22:54:38.588debugFront Light 2 workMode white

dev:16512024-03-18 22:54:38.583debugGroups: [Front Light 2:[[code:switch_led, value:false], [code:work_mode, value:white], [code:bright_value_v2, value:1000], [code:temp_value_v2, value:1000], [code:colour_data_v2, value:{"h":351,"s":1000,"v":1000}], [code:scene_data_v2, value:{"scene_num":1,"scene_units":[{"bright":200,"h":0,"s":0,"temperature":0,"unit_change_mode":"static","unit_gradient_duration":13,"unit_switch_duration":14,"v":0}]}], [code:countdown_1, value:0], [code:control_data, value:], [code:do_not_disturb, value:true]]]

dev:16512024-03-18 22:54:38.584infoFront Light 1 level is 100%

dev:16512024-03-18 22:54:38.582debugFront Light 1 status [code:bright_value_v2, value:1000]

dev:16512024-03-18 22:54:38.581infoFront Light 1 color mode is CT

dev:16512024-03-18 22:54:38.579debugFront Light 1 status [code:work_mode, value:white]

dev:16512024-03-18 22:54:38.477infoFront Light 1 switch is off

dev:16512024-03-18 22:54:38.473debugFront Light 1 status [code:switch_led, value:false]

dev:16512024-03-18 22:54:38.471debugFront Light 1 workMode white

dev:16512024-03-18 22:54:38.465debugGroups: [Front Light 1:[[code:switch_led, value:false], [code:work_mode, value:white], [code:bright_value_v2, value:1000], [code:temp_value_v2, value:1000], [code:colour_data_v2, value:{"h":351,"s":1000,"v":1000}], [code:scene_data_v2, value:{"scene_num":1,"scene_units":[{"bright":200,"h":0,"s":0,"temperature":0,"unit_change_mode":"static","unit_gradient_duration":13,"unit_switch_duration":14,"v":0}]}], [code:countdown_1, value:0], [code:control_data, value:], [code:do_not_disturb, value:true]]]

dev:16512024-03-18 22:54:38.432debugTuya category dj driver [driver:Generic Component RGBW, devices:[switch:[suffix:Switch, driver:Generic Component Switch], switch_1:[suffix:Socket 1, driver:Generic Component Switch], switch_2:[suffix:Socket 2, driver:Generic Component Switch], switch_3:[suffix:Socket 3, driver:Generic Component Switch], switch_4:[suffix:Socket 4, driver:Generic Component Switch], switch_5:[suffix:Socket 5, driver:Generic Component Switch], switch_6:[suffix:Socket 6, driver:Generic Component Switch], switch_usb1:[suffix:USB 1, driver:Generic Component Switch], switch_usb2:[suffix:USB 2, driver:Generic Component Switch], switch_usb3:[suffix:USB 3, driver:Generic Component Switch], switch_usb4:[suffix:USB 4, driver:Generic Component Switch], switch_usb5:[suffix:USB 5, driver:Generic Component Switch], switch_usb6:[suffix:USB 6, driver:Generic Component Switch]]]

dev:16512024-03-18 22:54:38.427debugTuya category dj driver [driver:Generic Component RGBW, devices:[switch:[suffix:Switch, driver:Generic Component Switch], switch_1:[suffix:Socket 1, driver:Generic Component Switch], switch_2:[suffix:Socket 2, driver:Generic Component Switch], switch_3:[suffix:Socket 3, driver:Generic Component Switch], switch_4:[suffix:Socket 4, driver:Generic Component Switch], switch_5:[suffix:Socket 5, driver:Generic Component Switch], switch_6:[suffix:Socket 6, driver:Generic Component Switch], switch_usb1:[suffix:USB 1, driver:Generic Component Switch], switch_usb2:[suffix:USB 2, driver:Generic Component Switch], switch_usb3:[suffix:USB 3, driver:Generic Component Switch], switch_usb4:[suffix:USB 4, driver:Generic Component Switch], switch_usb5:[suffix:USB 5, driver:Generic Component Switch], switch_usb6:[suffix:USB 6, driver:Generic Component Switch]]]

dev:16512024-03-18 22:54:38.422debugTuya category dj driver [driver:Generic Component RGBW, devices:[switch:[suffix:Switch, driver:Generic Component Switch], switch_1:[suffix:Socket 1, driver:Generic Component Switch], switch_2:[suffix:Socket 2, driver:Generic Component Switch], switch_3:[suffix:Socket 3, driver:Generic Component Switch], switch_4:[suffix:Socket 4, driver:Generic Component Switch], switch_5:[suffix:Socket 5, driver:Generic Component Switch], switch_6:[suffix:Socket 6, driver:Generic Component Switch], switch_usb1:[suffix:USB 1, driver:Generic Component Switch], switch_usb2:[suffix:USB 2, driver:Generic Component Switch], switch_usb3:[suffix:USB 3, driver:Generic Component Switch], switch_usb4:[suffix:USB 4, driver:Generic Component Switch], switch_usb5:[suffix:USB 5, driver:Generic Component Switch], switch_usb6:[suffix:USB 6, driver:Generic Component Switch]]]

dev:16512024-03-18 22:54:38.086debugAPI GET [uri:https://openapi.tuyaeu.com, path:/v1.0/devices/bfd67f61e5dd77c707pv2t/specifications, query:null, contentType:application/json, headers:[t:1710802478084, nonce:d30f14d5-254c-4d23-9411-45712c20bd7f, client_id:w5mwexadq8pqsmq3ganf, Signature-Headers:client_id, sign:39CDABAC9900BA0D17BB71734441E764537206EE270EBEFCBDCF22944C9EC2D2, sign_method:HMAC-SHA256, access_token:c867797f750ed8d5d31d6998af926ab9, lang:en, dev_lang:groovy, dev_channel:hubitat, devVersion:0.3], body:null, timeout:5]

dev:16512024-03-18 22:54:38.083infoRequesting cloud device specifications for bfd67f61e5dd77c707pv2t

dev:16512024-03-18 22:54:38.079debugAPI GET [uri:https://openapi.tuyaeu.com, path:/v1.0/devices/bfd4ff3fb20523d12ef4qi/specifications, query:null, contentType:application/json, headers:[t:1710802478078, nonce:d30f14d5-254c-4d23-9411-45712c20bd7f, client_id:w5mwexadq8pqsmq3ganf, Signature-Headers:client_id, sign:CE63F503AE4597A2D3B91D1AB2067BAD96F20798E06E95E8F6F57DED371BB11C, sign_method:HMAC-SHA256, access_token:c867797f750ed8d5d31d6998af926ab9, lang:en, dev_lang:groovy, dev_channel:hubitat, devVersion:0.3], body:null, timeout:5]

dev:16512024-03-18 22:54:38.077infoRequesting cloud device specifications for bfd4ff3fb20523d12ef4qi

dev:16512024-03-18 22:54:38.064debugAPI GET [uri:https://openapi.tuyaeu.com, path:/v1.0/devices/bf4fa9fcba36e0fd3bl9nv/specifications, query:null, contentType:application/json, headers:[t:1710802478063, nonce:d30f14d5-254c-4d23-9411-45712c20bd7f, client_id:w5mwexadq8pqsmq3ganf, Signature-Headers:client_id, sign:F84C528D38D6E0CF977492DAE7D26D784331AB44BA054A86BA664AAC6A61B1E3, sign_method:HMAC-SHA256, access_token:c867797f750ed8d5d31d6998af926ab9, lang:en, dev_lang:groovy, dev_channel:hubitat, devVersion:0.3], body:null, timeout:5]

dev:16512024-03-18 22:54:38.060infoRequesting cloud device specifications for bf4fa9fcba36e0fd3bl9nv

dev:16512024-03-18 22:54:38.058infoReceived 3 cloud devices (has_more: null)

dev:16512024-03-18 22:54:38.049debugAPI GET [uri:https://openapi.tuyaeu.com, path:/v1.0/homes/54225301/scenes, query:null, contentType:application/json, headers:[t:1710802478048, nonce:d30f14d5-254c-4d23-9411-45712c20bd7f, client_id:w5mwexadq8pqsmq3ganf, Signature-Headers:client_id, sign:79CFA542B802B64D41DF45395D47E9D64EEB4CDDBD3342A9986052717F04DA82, sign_method:HMAC-SHA256, access_token:c867797f750ed8d5d31d6998af926ab9, lang:en, dev_lang:groovy, dev_channel:hubitat, devVersion:0.3], body:null, timeout:5]

dev:16512024-03-18 22:54:38.046debugRequesting scenes for home 54225301

dev:16512024-03-18 22:54:37.752debugAPI GET [uri:https://openapi.tuyaeu.com, path:/v1.0/users/eu1648766256063p5Ddq/homes, query:null, contentType:application/json, headers:[t:1710802477751, nonce:d30f14d5-254c-4d23-9411-45712c20bd7f, client_id:w5mwexadq8pqsmq3ganf, Signature-Headers:client_id, sign:B9924427FCC3380027ADEDD9AEAD6F6CB338F2921171273CF4BB5F1572D36215, sign_method:HMAC-SHA256, access_token:c867797f750ed8d5d31d6998af926ab9, lang:en, dev_lang:groovy, dev_channel:hubitat, devVersion:0.3], body:null, timeout:5]

dev:16512024-03-18 22:54:37.749infoRequesting Tuya Home list

dev:16512024-03-18 22:54:37.745debugAPI GET [uri:https://openapi.tuyaeu.com, path:/v1.0/iot-01/associated-users/devices, query:[last_row_key:], contentType:application/json, headers:[t:1710802477744, nonce:d30f14d5-254c-4d23-9411-45712c20bd7f, client_id:w5mwexadq8pqsmq3ganf, Signature-Headers:client_id, sign:0673E9DA97CE99180456BA631151B146BEA30E10049580C3497B116F4FF4670A, sign_method:HMAC-SHA256, access_token:c867797f750ed8d5d31d6998af926ab9, lang:en, dev_lang:groovy, dev_channel:hubitat, devVersion:0.3], body:null, timeout:5]

Have you checked that your trial period has not expired, All my devives under Tuya stopped working last night, when i check the Tuya device I have an error and as stated on the first post, log into Tuya account and check the status of your account, you have to renew every 6 months

1 Like

I've succesfully added my devices, however when I send a on command to one of the switches, the lights just flicker on for half a second, and turn off again. Am I doing anything wrong?

Hi there! I am wondering if anyone has tried to make Tuya devices locally instead of through the cloud? There is a Home Assistant plugin that does this based on the TinyTuya project. The idea is that you setup an API dev account only initially to get the devices’ private keys. Once you have them, you can query the devices directly using that key to encrypt and decrypt the payloads. Neither one of those projects is written in java unfortunately…

hello all, got an alert from tuya that I was generating a ton of API calls, 85% of them to GET:/v1.0/devices/{deviceId}/specifications

I looked at the device source and didn't even see where this was called, but it seems to be generating 1000s per day according to them, any advice on how to troubleshoot would be great, thanks