[App][Pro] Tuya Cloud

Tuya cloud

This app is not active maintained, only Pull requests will be put through.

Homey App for the Tuya cloud.

The official API is supported now. It requires an extra development account and keys. The API is also returning keys for local control, so maybe it’s in the future also possible to local control devices. But commands are not yet available.
This app was based on the Home Assistant implementation. Tuya has an undocumented API for Home Assistant that differs from the official API. This old depricated API supports login with credentials only.

If you are already used this app, the existing devices will still use the old API!!!

You have to add the devices again to use the functionality of new API.
If You don’t need the legacy devices anymore, you can delete the legacy devices. When you don’t have legacy devices anymore, set the API dropdown to official only.

Supported devices

  • Light
  • Switch
  • Socket
  • PIR sensor
  • Smoke sensor
  • Contact sensor
  • Presense sensor
  • Air conditioner

Not supported devices or functions

Only when device is supported by API, it’s possible to add the device to this app. because I don’t own all device types, it’s hard to implement a device type which I don’t own. Contributions to code are welkom to add unsupported devices. Other possibility is to use raw commands

Raw commands

You can receive all messages send for devices with trigger cards. Also there are now action cards to send commands to you device. On this way you can interact with not directly supported devices are commands. Combine it with the virtual devices app and you can control most of your devices. It’s a function for advanced users, there is no validation when sending a command to your device.

To get the device id’s, commands and possible values you can create a flow with the text event received trigger card. This card is returning device id, command and value for each action. Log the returned values to log app to know the commands of your devices, deviceid’s and possible values.

See also Howto of @Peter_Kawa: [App][Pro] Tuya Cloud - #765 by Peter_Kawa

Existing legacy devices can be used as long as they are paired, but can’t be added anymore

  • Legacy Light ( On/Off, some devices brightness and color)
  • Legacy Switch( On/Off)
  • Legacy Cover

The official API( non legacy devices) is using push messages, so changes to devices should be direct visible, so no more 10 minutes waiting for updates.

Scenes

This app support the use of scenes. In the mobile Tuya/Smart life app you can make ‘Tap to run’ actions( In the past they where called scenes). Those actions can be called in a flow from this app.
The scenes for the official API are not automatically updated, for now new scenes will only appear after a restart of this app.

See also howto of @Peter_Kawa: [App][Pro] Tuya Cloud - #296 by Peter_Kawa

Setup Homey

To use the new API you should follow the same basic instruction as for Home assistant/ Homebridge.

  1. Tuya IoT Platform Configuration
    The services have some new names and are not updated in official Tuya documentation:
    -IOT Core ( Controlling devices from Homey)
    -Authorization => Authorization Token Management (Authentication)
    -IOT Data Analytics => Data Dashboard Service ( See devices in development portal)
    -Smart Home Scene linkage ( Needed for trigger scenes from Homey)
    -Device Status Notification ( Needed for getting data from Tuya to Homey)
  2. Go to the setup page in Homey mobile app or Homey develloper portal
  3. Set the APi to use to Official
  4. The authorization key acces key and secret from step 1have to be filled in on the settings page.
    The country code is used to determine which datacenter has to be used and must match with your android app and region of your project. Only the number is allowed, no leading zero’s or + sign. Look in the link for correct numbering, it can be different for some countries then the known phone prefix.
    Mappings Between OEM App Accounts and Data Centers-Documentation-Tuya Developer
  5. Username, Password are the same as with first login of the mobile app
    It won’t work with linked Cloud accounts like Google, Facebook or other!!!
    It’s your mobile phone app login credentials, and not develloper portal credentials!!!

AFTER creating and linking the IoT cloud project, one day you’ll receive an email message from Tuya.
They write: Your Tuya service subscription is about to expire and you’ll have to renew it.

It is safe to ignore. This API is free of charge.

Todo

  • Add other possible device types
  • Support renaming of devices (so Tuya device names and Homey device names stay in sync)
  • Translation of texts
    • Fixed text are now moved to language files
    • Dutch and English now supported
  • Add other manufacturer Tuya apps
  • Replace settings page by setting device

The last point is needed to support Homey Cloud, until this is fixed, Homey Cloud isn’t supported and only Homey PRO is supported.

Error Code and Troubleshooting

The app is passing the values to the Tuya API and if the API is giving back an error, you can find some solutions here. You can view the error on the settings page of this app. When on settings page, you must change some settings! (Without change, there is nothing to save…) and press after changing the save button, you should get an error message if there is something wrong or you get message to restart app. You can also use the test version, some om the errors should bubble to UI when using advanced flows.

Error code Message Troubleshooting
1004 sign invalid The Access ID and Access Secret you entered are not correct. For more information, see entering credentials step in Install Tuya Integration.
1106 permission deny
  • Your app account is not linked to your cloud project. This operation is a must-do. For more information, see Link devices by app account.
  • Incorrect account or password. You must enter the account and password of the mobile app that you use to scan the QR code for linking devices to your cloud project on the Tuya IoT Development Platform.
  • Incorrect country. You must select the region of your account of the Tuya Smart app or Smart Life app.
1100 param is empty Empty parameter of username or app. Fill the parameters refer to the entering credentials step in Install Tuya Integration.
2406 skill id invalid
| | 28841105 | No permissions. This project is not authorized to call this API | Insufficient API permissions. You need to subscribe to the required [API services](https://developer.tuya.com/en/docs/iot/applying-for-api-group-permissions?id=Ka6vf012u6q76#title-2-Subscribe%20to%20API%20services) and [authorize](https://developer.tuya.com/en/docs/iot/applying-for-api-group-permissions?id=Ka6vf012u6q76#title-3-Authorize%20project%20to%20call%20APIs) your cloud project to use these API services. The following API services are required.
  • Authorization
  • IoT Core
  • Smart Home Scene Linkage
  • IoT Data Analytics
  • Device Status Notification
|

Tuya Integration FAQs

Q1: I got an error shown in the following screenshot when I tried to scan a QR code to link my devices to my cloud project. How to fix it?

  • This is because the data center you selected for your cloud project cannot serve the region of your app account. You must switch to the correct data center and scan the QR code again.

    1. Here is how to find the region: open the mobile app you use and tap Me > Setting > Account and Security > Region.

    2. See Mappings Between OEM App Accounts and Data Centers and find the data center that can serve your region.

    3. (Optional) If you do not find the data center you want to use, click the Overview tab and then Edit to add data centers.

    4. Click the Devices tab > Link Tuya App Account. Select the correct data center from the drop-down menu in the top right corner and click Add App Account.

    5. Scan the QR code again to link devices.

Q2: Will I be billed after the free trial of the API service expires?

Q3: Can I request Tuya’s cloud services from an IP address outside the data center region?

Please note that data transfer across regions has a risk of violation of the data security regulations. If you request Tuya’s cloud services from an IP address outside the data center region, you are at risk of illegally transferring data. For example, using an IP address in the U.S.A. to access cloud services in China’s data centers will be regarded as data transfer across regions, and vice versa. Tuya will completely prohibit cross-region API calls and message subscriptions. Please deploy your cloud services properly to ensure data security.

12 Likes

Changelog

0.0.2 First version in App store

2 Likes

Great! Thanks for adding this app to homey. I already did a feature request on github; but can you add support for the water sensor? Here is a link to the product:

€ 15,47 26%OFF | NEO Smart WIFI Water Flood Sensor WIFI Water Lekkage Detector App Kennisgeving Waarschuwingen Water Sensor Alarm Lek Alarm Thuis Securit
https://s.click.aliexpress.com/e/0lwSFZ3XH

1 Like

Sensors are currently not supported by the Tuya API. When the Tuya API supports sensors, I will look into it.

I have this thingie conected via this app:

4 sockets to be operated separately. 4 USB ports to be operated as 1 switch. And 1 switch to turn them all on/off at once.
Needed to build in a delay of 2 seconds to turn all the sockets on tho.

4 Likes

Great App. I bought myself an LSC Smart light by the Action and it works verry good

1 Like

Did you try to make a scene inside Tuya/Smart life app where you turn on or off all the sockets and call this scene from homey? I do this for my 6 living spots and works well. They turn on and off faster then my lights in dinner room which still have Ikea zigbee spots ( tried direct to homey and gateway).

Gonna try, ill let u know.

Edit: Did try to make a mood but same behavior. So maybe some interference from some other devices here.

1 Like

Too bad the solution didn’t work for you.

Hi @Jurgen_Heine.
I have a color problem with the lights from several brands (Deltaco and Kjell) using your app.

Example:
Deltaco SH-LE27RGB-f160 adds nicely and everything but color works great.
The device does not have a color wheel.

Using the other Tuya app the devices have the color wheel and all is working.

Any ideas what’s wrong?

This looks promising. I have 2 ceiling fans that uses TUYA embeded controllers… I use the smart life app to control them… looking forward to this app supporting fans!

1 Like

How can you use a mood? I have a few moods in my smart life app, but homey says there’s nothing?

Can u also try that with the Tuya app instead of the smart life app?

Haven’t tried the Tuya app, because I like the smart life app better. But this is maybe the problem, when it only works with the tuya app.
I use a hue motion sensor in the bathroom with the lsc ceiling light, so it would be nice to use the moods, for example morning, day and night

is it possible to add the LCS Sirene to the app. The app itself look good, but it didn’t find the sirene, i saw only 2 options for adding.

@johan_bendz, how are those lights coupled in the Tuya/Smart life app? If this is ledstrip, then colors don’t work in Homey. This app uses the Home Assistant Tuya API which not supporting this for ledstrips yet. The other App is using a different method with local control. You can stay with that app, also you can control the colors with scenes.

@viix, fans are possible to add. I have to look into this, I don’t own one of those. Maybe you can help testing when I add those.

@Marina_Rietveld, I am using Smart life myself and should work. But I looked this morning in Smart life app and they changed the user interface. I still see my scenes, but they are called in the app now “tap-to-run”. You have now set condition to “click to execute” and in the task you define what your device has to do. The name you enter here is also the name of the mood in Homey. This name was limited, but not anymore. It looks like too long names are not working correctly.

@marcel_ridder, Sirens are not possible at the moment.

That’s correct Jugen, I have a few of these tal-to-run but none of them are visible?!
homey|241x500


Have you tried to set a mood?

1 Like

Yes, I have made a test this morning. The last one is the test mood of this morning.

But can you see/select it when you make a flow?

When I select “kies een item” there is nothing