How do I get Tuya IDs and Secrets?

I have been racking my brain for several days over this and I do not know what to do. I have a RainPoint hose controller that came with the hub and outlet. I kind of would like to get the two-valve one but I need to figure this out before I go for that.

I added the hub successfully to the Tuya Smart App and it works perfectly in that app. I even used the app to obtain my virtual IDs of the devices. And, I set up a DHCP reservation to guarantee the device has the same IP Address all the time on my network.

I saw there was a LocalTuya HACS integration that I downloaded, along with the regular Tuya application.

On the local Tuya application, it wants the following information:
Client ID: (I assume the hub or can I go individual devices)
Secret: I have been all over the app and I do not see where this value is, anywhere.
User ID: I assume this is my Tuya account.

On the native Tuya integration, it wants my credentials:
Tuya IoT Access ID: Is that the virtual ID of the hub or individual devices?
Tuya IoT Access Secret: Here, again, I assume this is somewhere but I cannot find it anywhere.
Account: I assume my Tuya Smart username
Password: I assume my Tuya Smart password.

It seems it is that secret that I cannot find anywhere in the app is my big stumbling block. I even signed up for the developer page but I cannot figure out how to get the devices I own into that. I did see where it will get you that secret that I cannot find in the app.

Thank you in advance.

And I am not opposed to replacing a hose valve with something that works better if people have recommendations. I have Zigbee and Z-Wave range.

Access to ID/Secret

As for LocalTuya here is how I reliably do it for years:

If you have already signed up for the developer account at iot.tuya.com and have registered your Tuya device(s) with that account you will have an “API key” and “API secret” from tuya.com. Also check on one of the ‘virtual ID’ of a device currently registered in the app.

For more detailed information take a look at codetheweb / tuyapi.

Open a CLI (on any Linux device which is connected to the internet).

Check whether npm (Node Package Manager) is installed:
sudo npm --version

If npm is not installed run for Debian and derivatives:
sudo apt install npm

Now install/update tuya-cli:
sudo npm i -g @tuyapi/cli

Now have your Tuya “API key”, the “API secret” and the “virtual ID” of one of your devices registered in the app ready and run “tuya-cli wizard”:
sudo tuya-cli wizard

On the CLI you will see something similar to the following:

- The API key from tuya.com: <type-in-your-api-key>
- The API secret from tuya.com: <type-in-your-api-secret>
- Provide a "virtual ID" of a device currently registered in the app: <type-in-the-virtual-id>

You’ll see an output similar to the following:

[
  {
    name: '<device-name> ',
    id: '<some-string>',
    key: '<another-string>'
  }
]

The above command will list all registered devices, their names, id’s and keys. It’s wise to copy the whole output into a text file to have it ready at hand, especially if you have many devices.

After you have installed the LocalTuya integration with HA go to the Integrations page, look for “localtuya” and click on “Configure”.

Now check “Add a new device” and pick or add a device to configure:
Name = the device-name
Host = the IP address of the particular device.
Device ID = <see above tuya-cli wizard output for id:>
Local key = <see above tuya-cli wizard output for key:>

Note: Whenever you have to reset one (or more) of your Tuya devices using the Smart Life app the Local key(s) will change. Thus you will need to run sudo tuya-cli wizard again from the CLI to obtain the new Local key(s). Within the LocalTuya integration at HA you don’t want to check on “Add a new device” but use “Edit a device” instead to change the Local key accordingly.

3 Likes

I am moving away from Tuya devices bit by bit and replace(d) those with Zigbee devices. Those are much more reliable and really “foreign cloud free”.

2 Likes

There are multiple local tuya integrations. The rospogrigio one is probably the most flexible, but that comes with complexity and I’ve never worked it out. However, if you go through the motions of adding a device with this integration, it will fetch the device-id and local key. Very handy.

Then I just copy/paste into the make-all one I use. I leave the first integration installed, but with no devices.

Of course that assumes you can first see all your devices in Tuya IoT Cloud, as per the steps above.

My Tuya cloud trial is expired and I was unable to find local id and DP as It gives error using the API explorer as mentioned in various Youtube videos and blogs. A recent article Getting Tuya Device ID, Local Key and DP ID using Tuya Smart Home Basic Service helped me out even expiration of my Tuya Cloud Trial.

1 Like

Hey. Thanks for the info Ahmegas!! This really helped me out for getting the local key again for a device that was factory reset. Kudos!!

Hello.

I have 98 Tuya devices in my home, and I would like to make all automations locals, not to depend any longer on Tuya Cloud, that is actually mainly hosted on AWS Cloud (A double moral fault to my humble crypto-anarchist opinion).

It’s like I am going to be forced to get those details with tuya-cli device per device, this is going to be a pain. I will do it if I am forced to do it, but I could see that there was a command ( list-app ) that used to give them all with one unique request, but it’s like it is deprecated.

I hope the folks who took time to implement local tuya will have the kindness to push just a little harder to that its usage and integration into HA be more easy and automatable.

Kind regards,

Frederic.

Welcome to the forum, Frederic :wave:t3:

Honestly, in the meantime I moved away from tuya wifi based devices. It was a hard move because I had many of them. The final blow came when we experienced an internet blackout for 3 days: Despite the claims of being “local” (used Local Tuya) one by one felt off and after two days none of the tuya wifi based devices were controllable through HA. Obviously they are not that “local” after all.

I moved on to Zigbee with Z2M and never looked back again. All really local with Zigbee amd I don’t regret the move.

PS. Even if you use Local Tuya or Tuya Local you will still need to login to your Tuya Developer account every 6 month to extend your trial period for another 6 month to come. It feels very much like you have to beg them to extend your trial :pray:t3: If you don’t do that (begging for extention of your trial period) your tuya wifi devices will stop working after your trial is over. Ridiculous!

I got the API key by asking the chat ai:

  1. Log in to the Tuya Developer Platform.
  2. Create a Cloud Project under the Cloud section.
  3. During project creation, select Industry Basic Service, Smart Home Basic Service, and Device Status Notification.
  4. Once the project is created, go to the Overview page to get the Authorization Key used for API requests.