codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.04k stars 332 forks source link

Setup instructions no longer match the tuya web site #547

Open code-surfer opened 2 years ago

code-surfer commented 2 years ago

I'm trying to follow the guide in the section "Linking a Tuya device with Smart Link".

The 2. step "go to Cloud -> Projects" is already not working as described. I'm guessing that I have to use the "Development" tab and click on "Create Cloud Project". I get access id and secret there.

For the 3. step, I get as far as "Go to authorize", but in the "Select API" dropdown there is no "Smart Home Devices Management". It seems this step is not needed.

Following the "Listing Tuya devices from the Tuya Smart or Smart Life apps" section:

Running the code samples from the "Basic Usage" section of the README works, it turns the panel off/on.

Inchworm333 commented 2 years ago

I couldn't get it to work until I added the IoT Core service. After adding the trial version it worked fine

UsefulVid commented 2 years ago

There seems to be a solution for Step 3: https://github.com/codetheweb/tuyapi/issues/537#issuecomment-968155559

Nevertheless the tuya cli wizard exits with There was an issue fetching that device. Make sure your account is linked and the ID is correct. It asks for "API Key" I guess this is "Access ID/Client ID" and the "API Secret" is "Access Secret/Client Secret". I also entered my virtual ID (same on App and on "Devices") but the error appears :( edit: with debug I found the glitch: I missed the IoT Core authorization.

QHose commented 2 years ago

Somehow I can’t add more services to my existing project in tuya.com…. Now the cli fails

mhendu commented 2 years ago

I'm configuring now and don't see any 'IoT Data Analytics' API. Crossing my fingers it works without this.

paukstelis commented 2 years ago

I'm working on this too. What I am running into is that I can link the app account successfully, but the devices I have registered in that app account aren't there. It always shows devices as 0.

EDIT: I had to use Western America DataCenter instead of Eastern. Who would have thought?

Shaun-R commented 2 years ago

I also had this trouble. Please see below updated instruction set:

Listing Tuya devices from the Tuya Smart or Smart Life apps

This method is fast and easy. If you're having trouble manually linking your device with the below method, we recommend you try this. All devices that you want to use must be registered in either the Tuya Smart app or the Smart Life app.

  1. Follow steps 1 through 4 from the "Linking a Tuya device with Smart Link" method below, ensuring that you select the matching Data Center for your Tuya app based on this list e.g. for USA you must choose Western American Data Center, for UK, Australia, ensure you create your project in the Central Europe Data Center, etc. as applicable.
  2. Go to Cloud -> Development and click the project you created earlier. Then click the "Devices" tab. Click the "Link Tuya App account" tab.
  3. Click "Add App Account" and scan the QR code from your smart phone/tablet app by going to the 'Me' tab in the app, and tapping a QR code / Scan button in the upper right. Your account will now be linked.
  4. From the All Devices tab, note your Device ID as this will be required in the next step.
  5. On the command line, run tuya-cli wizard. It will prompt you for your Access ID and Access Secret (available from the Cloud -> Development -> Overview section) and your Device ID. It will then list out all your device names, IDs, and keys for use with TuyAPI. Copy and save this information to a safe place for later reference.

Linking a Tuya device with Smart Link

This method requires you to create a developer account on iot.tuya.com. It doesn't matter if the device(s) are currently registered in the Tuya Smart app or Smart Life app or not.

  1. Create a new account on iot.tuya.com and make sure you are logged in. Select United States as your country when signing up. This seems to skip a required verify step.
  2. Go to Cloud > My Services in the left navigation drawer. From here, you need to "Subscribe" to the Free versions of a. IoT Core b. Authorization c. Smart Home Scene Linkage d. Data Dashboard Service
  3. Go to Cloud -> Development in the left nav drawer. Click "Create Cloud Project". Make sure you select "Smart Home" for both the "Industry" field and the development method. Select your country of use in the for the location access option, and feel free to skip the services option in the next window. After you've created a new project, click into it. The access ID and access key are equivalent to the API key and API secret values need in step 7.
  4. Go to Cloud -> Development -> "MyProject" -> Service API -> "Go to authorize". "Select API" > add the previously-subscribed IoT Core, Authorization, Smart Home Scene Linkage, and Data Dashboard Service.
  5. Go to App -> App SDK -> Development in the nav drawer. Click "Create" and enter whatever you want for the package names and Channel ID (for the Android package name, you must enter a string beginning with com.). Take note of the Channel ID you entered. This is equivalent to the schema value needed in step 7. Ignore any app key and app secret values you see in this section as they are not used.
  6. Go to Cloud -> Development and click the project you created earlier. Then click "Link Device". Click the "Link devices by Apps" tab, and click "Add Apps". Check the app you just created and click "Ok".
  7. Put your devices into linking mode. This process is specific to each type of device, find instructions in the Tuya Smart app. Usually this consists of turning it on and off several times or holding down a button.
  8. On the command line, run tuya-cli link --api-key <your api key> --api-secret <your api secret> --schema <your schema/Channel ID> --ssid <your WiFi name> --password <your WiFi password> --region us. For the region parameter, choose the two-letter country code from us, eu, and cn that is geographically closest to you.
  9. Your devices should link in under a minute and the parameters required to control them will be printed out to the console. If you experience problems, first make sure any smart phone/tablet app that you use with your devices is completely closed and not attempting to communicate with any of the devices.
Shaun-R commented 2 years ago

What I am running into is that I can link the app account successfully, but the devices I have registered in that app account aren't there. It always shows devices as 0.

I was having this same trouble until I found this guide advising of the country mappings between the Tuya App vs the data centre, and how the project on iot.tuya.com needs to be in the same data centre as the app - else you end up with 0 devices. As soon as I changed my project data centre, my devices in the Tuya app instantly showed up!

I've re-written the guide to be clearer about this (see above comment)

codetheweb commented 2 years ago

@Shaun-R feel free to PR your changes. :)

Shaun-R commented 2 years ago

@codetheweb Wouldn’t have a clue how to, happy to give it a go, but you’re welcome to copy-paste if you like.

lollix91 commented 2 years ago

Hello, does the Free service subscription for the services does not exist anymore? I can only use the Free-trial version o services, that lasts one month.

jampy commented 2 years ago

Hello, does the Free service subscription for the services does not exist anymore? I can only use the Free-trial version o services, that lasts one month.

Same. Do you have any updated information?

nitrog0d commented 1 year ago

^