codetheweb / tuyapi

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

tuya-cli link-wizard timeout #80

Closed wmbrown2 closed 6 years ago

wmbrown2 commented 6 years ago

I have been trying for a few hours to successfully register a plug that I am able to setup via the smartlife app. I have read through a few of the threads and tried everything that was suggested. Attached is output of the program. Is there anything within the file that points to an obvious oversight of mine?

Although this should not have been an issue I removed satellite APs from my mesh network and ensured that my computer was connected to my network via 2.4Ghz. I cannot think of anything else that would be different between my phone's access to the network and my computer's.

node v8.11.4

$ npm -v tuya-cli 5.6.0

tuya_cli_link_timeout.txt

codetheweb commented 6 years ago

Everything looks good.

Judging by the other thread, there seems to be a common issue but I have no idea what it is. I doubt this will do anything, but can you try updating your Node version to >=10?

Also, npm -v tuya-cli spits out the version of NPM, not the package. Try npm list @tuyapi/cli -g to get the package's version (should be 1.2.0).

wmbrown2 commented 6 years ago

I updated node to v10.10.0 and confirmed that @tuyapi/cli is version 1.2.0. The result was the same.

The debug output is attached. timeout_debug.txt

wmbrown2 commented 6 years ago

Is this common issue you mentioned a relatively new issue that has emerged? Also, does the wizard contact tuya at the beginning to use its API? I ask only because it looks like there is a concept of requesting authorization to call their cloud API from a third-party cloud. It is found in Dashboard > User > Account - Cloud API Authorization.

codetheweb commented 6 years ago

Not really a new issue, just popped up as people other than me started using it.

The linking process does contact Tuya to get an access token for device setup. The authorization part of the cloud package is not at fault; if it was Tuya would return an error not a result.

What's the general area in which you live (i.e. the EU, US, Africa, etc.)? What's your timezone?

wmbrown2 commented 6 years ago

I am on the east coast of US hoping to dodge Florence!

My ultimate goal is to build off of your work to integrate this with Smartthings, but I have to get it working first!

codetheweb commented 6 years ago

Well, until I get more data from other people to try to figure out this issue, there's not much I can do. Can you post a link to the product page of your device?

wmbrown2 commented 6 years ago

I completely understand.

Smart plug, Gosund Mini Wifi Outlet Compatible with Alexa, Google Home & IFTTT, No Hub Required, Remote Control your home appliances from Anywhere, ETL Certified (4 packs) https://www.amazon.com/dp/B079MFTYMV/ref=cm_sw_r_cp_api_KURMBb0TGJRBZ

codetheweb commented 6 years ago

Created a short survey in an attempt to collect more data, I'd appreciate it if you took it: https://codetheweb.typeform.com/to/rTXsWg. Thanks.

enkia commented 6 years ago

I'm having the same issue. I filled out the survey just now.

? Do you want to save devices that are successfully linked? Yes
✖ Device(s) failed to be registered!
Error: Timed out wating for device(s) to connect to cloud
    at Promise (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/cloud/index.js:275:12)
codetheweb commented 6 years ago

I received a note from someone who said they had a similar issue until they updated their device's firmware. Can you please try adding your device back to the app, updating the firmware, and then attempting to use the link wizard again?

enkia commented 6 years ago

I updated the firmware but that wasn't the issue. This is my first time setting up a Raspberry Pi for smart home use and so I believe I made a noob mistake in that I installed this cli on my main computer, rather than the raspberry pi itself. Once I ran it from the PI, it registered just fine!

codetheweb commented 6 years ago

Hmm, it should have worked on both computers. What OS is your main computer? Does it have a wireless adapter, or is it connected to your network over ethernet? @enkia

enkia commented 6 years ago

I'm running macOS Sierra 10.13.6. I tried on an iMac as well as on a Macbook to get closer to the PI. Both timed out and are connected wirelessly using the same network as the PI, yep.

codetheweb commented 6 years ago

What's the NodeJS version on all 3 computers?

enkia commented 6 years ago

Apologies for the late response!

Macbook: v10.4.1 iMac: v10.6.0

StoatsCoding commented 6 years ago

I had trouble with timeouts while adding my 2 plug devices after changing my network SSID. Used the same pi 3 I used before but had no luck this time. Upgraded everything but still got timeouts. Started to fill out the survey and didn't realize I only tried while the pi was connected to ethernet (same subnet in the end though). Switched to wifi on the pi and it worked ... got different private local keys from before though?

codetheweb commented 6 years ago

@StoatsCoding the local keys are different every time you run the linking process. Are you saying that the Pi had to be connected via WiFi to your network for it to work?

alfb113 commented 6 years ago

I can confirm that changing to wifi in place of a wired connection for the pi was successful. Previously I had the exact symptom that was mentioned above.

erichter2018 commented 6 years ago

I'm having the same problem, and it happens whether my PC (windows 10) is on a wired or wireless connection.

C:\WINDOWS\system32>tuya-cli link-wizard ? Make the indicator light on your device flash. For most devices, this means holding down the main button. Press return when it's blinking. Yes ? What's your WiFi called? R ? What's the password for your WiFi? [hidden] ? How many devices do you want to link? 1 ? Do you want to save devices that are successfully linked? Yes × Device(s) failed to be registered! Error: Timed out wating for device(s) to connect to cloud at Promise (C:\Users\erich\AppData\Roaming\npm\node_modules\@tuyapi\cli\node_modules\@tuyapi\cloud\index.js:275:12) at

erichter2018 commented 6 years ago

Here is my debug... tuya_cli debug.txt

codetheweb commented 6 years ago

Still not sure what the issue is, sorry @erichter2018. I'm going to try and do some digging tonight.

Moving thread to #65.