tuyapi
tuyapi copied to clipboard
Setup instructions no longer match the tuya web site
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:
- step 1. with steps above somehow done
- step 2. done
- step 3. done
- step 4. The wizard asks for a "virtual ID". Using the "Device ID" from my list of devices on the tuya page seems to work.
Running the code samples from the "Basic Usage" section of the README works, it turns the panel off/on.
I couldn't get it to work until I added the IoT Core service. After adding the trial version it worked fine
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.
Somehow I can’t add more services to my existing project in tuya.com…. Now the cli fails
I'm configuring now and don't see any 'IoT Data Analytics' API. Crossing my fingers it works without this.
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?
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.
- 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.
- Go to Cloud -> Development and click the project you created earlier. Then click the "Devices" tab. Click the "Link Tuya App account" tab.
- 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.
- From the All Devices tab, note your Device ID as this will be required in the next step.
- 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.
- 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.
- 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
- 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.
- 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.
- 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 theschema
value needed in step 7. Ignore any app key and app secret values you see in this section as they are not used. - 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".
- 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.
- 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 fromus
,eu
, andcn
that is geographically closest to you. - 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.
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)
@Shaun-R feel free to PR your changes. :)
@codetheweb Wouldn’t have a clue how to, happy to give it a go, but you’re welcome to copy-paste if you like.
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.
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?
^