# \[APP\]\[Pro\] Tuya Cloud - This app allows you to connect Homey to the Tuya cloud

**URL:** <https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313>\
**Category:** Apps\
**Tags:** app, unofficial, wifi, homey-pro\
**Created:** [November 25, 2019, 5:31pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313 "2019-11-25T17:31:12Z")\
**Posts on this page:** 20\
**Page:** 47

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 2, 2022, 2:42pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/940 "2022-09-02T14:42:38Z")

</div>

> [@Erwin\_Spierts](#):
>
> Unlink account is not possible since I cannot see the linked account, see first screenshot.

This is my option? Unlink link is present. _I use Tuya Smart app by the way_

> ![Screenshot_20220902-164022_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/b/1b6d7ce6045b3e1457a6f6f0224d5f0081b78fda.jpeg)

> ![Screenshot_20220902-164117_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/8/d8d639b78ced56bbd03c90c7dd80d467bf723f13.jpeg)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [September 2, 2022, 2:43pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/941 "2022-09-02T14:43:49Z")

</div>

@Jurgen_Heine @Grzegorz_Zalewski  
I checked the code and found these differences:

- light device:  
uses` await this.operateDevice` to set values  
that is based in basedriver.js and calls `this.homey.app.oldclient.device_control`, based in lib/cloudtuya.js

I used th eairconditioning as blueprint for the heater.

- heater device  
uses `this.sendCommand`  
that is based in heater/device.js and in this function `this.homey.app.tuyaOpenApi.sendCommand` is called, based in lib/tuyashopenapi.js

So these devices are using different APIs. What’s the right one?

---

<div class="post-metadata">

**Author:** ![Erwin\_Spierts](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erwin_spierts/32/17180_2.png) [@Erwin\_Spierts](https://community.homey.app/u/Erwin_Spierts)\
**Post date:** [September 2, 2022, 2:45pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/942 "2022-09-02T14:45:41Z")

</div>

Thanks but unfortunately not. No devices are shown there as can be seen in the screenshot below. When I press the button add app acount I got the message from previous post. Looks like a chicken egg problem.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/d/4d42b698e7bfa67f1755e8a51becc5fde49dedb1.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 2, 2022, 2:50pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/943 "2022-09-02T14:50:58Z")

</div>

What if you hit “switch project” and pick your other project?

---

<div class="post-metadata">

**Author:** ![Erwin\_Spierts](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erwin_spierts/32/17180_2.png) [@Erwin\_Spierts](https://community.homey.app/u/Erwin_Spierts)\
**Post date:** [September 2, 2022, 2:59pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/944 "2022-09-02T14:59:32Z")

</div>

Same thing.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Heine](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jurgen_heine/32/15323_2.png) [@Jurgen\_Heine](https://community.homey.app/u/Jurgen_Heine)\
**Post date:** [September 2, 2022, 3:21pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/945 "2022-09-02T15:21:08Z")

</div>

@RonnyW There are 2 light devices and drivers. Folder with light is old and the TuyaLight folder is the new one. The first uses indeed the old API ooerateDevice and is deprecated and second one uses sendCommand

---

<div class="post-metadata">

**Author:** ![Jurgen\_Heine](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jurgen_heine/32/15323_2.png) [@Jurgen\_Heine](https://community.homey.app/u/Jurgen_Heine)\
**Post date:** [September 2, 2022, 3:33pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/946 "2022-09-02T15:33:12Z")

</div>

@Roger_Gorissen there are no errors and I see in return message the following:  
log] 2022-09-02 10:56:01 [TuyaCloudApp] TuyaOpenAPI response: {“code”:2001,“msg”:“device is offline”,“success”:false,“t”:123456,“tid”:“xxxxxxx”} ( id’s replaced). So your device is not reachable by cloud api and probably only local control with Smart life/Tuya app.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [September 2, 2022, 3:36pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/947 "2022-09-02T15:36:34Z")

</div>

I checked again in debuger. The API returns a “invalid token” result with code 1010 although the token should have a longer lifetime based on the token expirer timestamp.  
I changed the API code a bit to solve this error code :

```auto
    async sendCommand(deviceID, params) {
        this.log.log("TuyaSHOpenAPI: sendCommand()");
        let res = await this.post(`/v1.0/devices/${deviceID}/commands`, params);
        this.log.log("TuyaSHOpenAPI: sendCommand result:");
        this.log.log(res);
        
        if (res.success == false && res.code == 1010){
            // force re-auth
            this.tokenInfo.expire = 0;
            this.log.log("Error on sendCommand, force re-auth.")
            res = await this.post(`/v1.0/devices/${deviceID}/commands`, params);
            this.log.log("TuyaSHOpenAPI: sendCommand result:");
            this.log.log(res);
        }

        return res.result;
    }

```

I added some log lines and the IF statement which cleares the token expire timestamp and calls the POST function again, which is refreshing the token.  
That’s working fine now. I will check it today and if all if ok, I will create a PR - if fou prefer this change, too.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Heine](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jurgen_heine/32/15323_2.png) [@Jurgen\_Heine](https://community.homey.app/u/Jurgen_Heine)\
**Post date:** [September 2, 2022, 4:04pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/948 "2022-09-02T16:04:43Z")

</div>

@RonnyW this is fine for me too. Strange that the token is invalid before expire time and that it, for now, only effects the heater.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [September 2, 2022, 4:35pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/949 "2022-09-02T16:35:42Z")

</div>

Yes, very strange. Perhaps it affects new added devices? Who knows. The main thing is that it works now for me 😄

---

<div class="post-metadata">

**Author:** ![Roger\_Gorissen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/roger_gorissen/32/9534_2.png) [@Roger\_Gorissen](https://community.homey.app/u/Roger_Gorissen)\
**Post date:** [September 2, 2022, 4:47pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/950 "2022-09-02T16:47:01Z")

</div>

Ah, that brings us somewhere. At least I think.

Are it the values at “t” or the “tid” that shows that to you?

Do I have to change something in the Smartlife app? Do you know perhaps?

---

<div class="post-metadata">

**Author:** ![Jurgen\_Heine](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jurgen_heine/32/15323_2.png) [@Jurgen\_Heine](https://community.homey.app/u/Jurgen_Heine)\
**Post date:** [September 2, 2022, 5:27pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/951 "2022-09-02T17:27:43Z")

</div>

@Roger_Gorissen I posted the complete return message( in JSON format) with msg part who saing this. This is what the Tuya API is returning.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Heine](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jurgen_heine/32/15323_2.png) [@Jurgen\_Heine](https://community.homey.app/u/Jurgen_Heine)\
**Post date:** [September 3, 2022, 9:47am UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/952 "2022-09-03T09:47:27Z")

</div>

There is new test version with fix for authentication problems heater by @RonnyW

---

<div class="post-metadata">

**Author:** ![Wouter\_Rijkhoff](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wouter_rijkhoff/32/56863_2.png) [@Wouter\_Rijkhoff](https://community.homey.app/u/Wouter_Rijkhoff)\
**Post date:** [September 5, 2022, 12:57pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/953 "2022-09-05T12:57:06Z")

</div>

Hello, switching recently to the new API, my screen switches are not working anymore. Tuya app is working perfectly, but the homey Tuya cloud app has no control over them. I removed all screen switches from Homey and added them again, but still it does not work. Other things like curtain switches in the Homey Tuya app are working.  
What can be the issue?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 5, 2022, 3:16pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/954 "2022-09-05T15:16:20Z")

</div>

They’re probably not supported as Homey device. Look for “tap-to-run”, or “raw commands” in post #1, so you can control them with a workaround

---

<div class="post-metadata">

**Author:** ![Wouter\_Rijkhoff](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/wouter_rijkhoff/32/56863_2.png) [@Wouter\_Rijkhoff](https://community.homey.app/u/Wouter_Rijkhoff)\
**Post date:** [September 5, 2022, 4:38pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/955 "2022-09-05T16:38:28Z")

</div>

Thanks for the tip Peter, but the strange thing is that they were working with this app until i got messages to switch to the new API which i did. These are also quite common screen switches.  
With a new API it should be backwards compatible.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 5, 2022, 4:48pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/956 "2022-09-05T16:48:19Z")

</div>

Well, if you were a customer of a paid app, what you say makes sense.

But I don’t know if you realize the real world here.  
Jurgen is just a unpaid volunteer, working for us in his spare hours, and dependent on whatever Tuya provides.

So, imho “should be backwards compatible” is not always easy to realize or taken care of in a few minutes.  
Let’s not forget Tuya is quitting the legacy api…

I’ve had the other way round experience: my PIR sensors (nothing battery operated) were supported in the legacy api, but now they are in the official api.

It’s just how things go imho

> [@Wouter\_Rijkhoff](#):
>
> These are also quite common screen switches

The issue is, they all look similar, but can have different firmware;  
For instance, often a device from last year works fine, but a recent one isn’t working.

---

<div class="post-metadata">

**Author:** ![Dennis\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dennis_d/32/34994_2.png) [@Dennis\_D](https://community.homey.app/u/Dennis_D)\
**Post date:** [September 5, 2022, 7:08pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/957 "2022-09-05T19:08:55Z")

</div>

Awesome! This works perfect for my curtains now!  
They stopped working after new API, but now they are working again!  
Thanks for this great workarround 👍

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 5, 2022, 7:23pm UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/958 "2022-09-05T19:23:44Z")

</div>

YW, but thank @Jurgen_Heine to make it happen 😉  
Don’t know if you can set your curtains to a certain position now, otherwise try this

> [@\[APP\]\[Pro\] Tuya Cloud - This app allows you to connect Homey to the Tuya cloud](https://community.homey.app/t/app-pro-tuya-cloud/21313/765):
>
> When adding a device is not possible, try using the so called RAW Commands functionality. Howto: -With the flow below, you´ll be able to “listen” to event messages of your devices; In this example a message of the ‘text’ type, which will return text, numeric and yes/no values. So, when you trigger the device you want to control from the Tuya Smart mobile app ([Google store](https://play.google.com/store/apps/details?id=com.tuya.smart&pli=1) / [Apple store](https://apps.apple.com/nl/app/tuya-smart/id1034649547)), or the SmartLife mobile app ([Google store](https://play.google.com/store/apps/details?id=com.tuya.smartlife) / [Apple store](https://apps.apple.com/nl/app/smart-life-smart-living/id1115101477)) or when you just activate a sensor, you’ll catc…

---

<div class="post-metadata">

**Author:** ![Elinu](https://avatars.discourse-cdn.com/v4/letter/e/919ad9/32.png) [@Elinu](https://community.homey.app/u/Elinu)\
**Post date:** [September 6, 2022, 7:53am UTC](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313/959 "2022-09-06T07:53:31Z")

</div>

Hi @Jurgen_Heine, thank you for the wonderful work so far. Would it be possible to add support for the Tuya smart knob (wireless dimmer switch)?

[Previous page](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313.md?page=46)

[Next page](https://community.homey.app/t/app-pro-tuya-cloud-this-app-allows-you-to-connect-homey-to-the-tuya-cloud/21313.md?page=48)
