/com.tuya.cloud

Connect homey to the Tuya cloud - Greg fork

Primary LanguageJavaScriptMIT LicenseMIT

${{\color{red}I\ am\ stopped\ with\ developping\ this\ app.\ I\ moved\ to\ Home\ Assistant.}}$

There is currently no new app developer yet. If somebody is making a PR, I will merge and publish it to the appstore.

Look first at Homey community forum for answeres and support.

On the community forum you can get answeres and support for your issues by me or other users. This site is only for sourcecode, contribution, development bugs and new device requests. Configuration problems are not development bugs!!! Problems with configuration are mostly not following the Tuya manual correctly, copy-paste errors or expired subscription. This app is only sending the values requested by Tuya top operate your device. Me and other contributors are not working for Tuya or Athom and are not responsible for changes on their platform.

Tuya cloud

image https://homey.app/nl-nl/app/com.tuya.cloud/Tuya-cloud/

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, and you did not switch already to new API, 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.

If yor device stops working with new API, your subscription is ended and has to be renewed.

Again, go to forum for latest info on this issue

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: https://community.homey.app/t/app-pro-tuya-cloud/21313/765

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: https://community.homey.app/t/app-pro-tuya-cloud/21313/296

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!!!! image

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.

Run locally for development

  1. Run npm install
  2. Run npm start

Error Code and Troubleshooting

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 and authorize 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.

      image

    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.

      image

    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.

      image

    5. Scan the QR code again to link devices.

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

  • After your API service expires, go to Cloud > My Services on the Tuya IoT Development Platform to request extending your API service by up to 6 months.

    1. Click Extend Trial Period.

      image

    2. Complete this form.

      image

    3. You will get the result within one working day.

      image

  • The Trial Edition allows you to use all free API services but puts limits on the quota of API calls. For more information about the quota, see Pricing.

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.