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