Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeout failure connecting devices via cli #124

Open
nortwood opened this issue May 10, 2021 · 10 comments
Open

timeout failure connecting devices via cli #124

nortwood opened this issue May 10, 2021 · 10 comments

Comments

@nortwood
Copy link

nortwood commented May 10, 2021

I'm unable to connect Sylvania Smart+ bulbs via cli (or apps).

× Device(s) failed to be registered!
Error: Timed out waiting for devices to connect.
at TuyaLinkWizard.linkDevice (C:\Users\user\AppData\Roaming\npm\node_modules@tuyapi\cli\node_modules@tuyapi\link\index.js:117:17)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async link (C:\Users\user\AppData\Roaming\npm\node_modules@tuyapi\cli\lib\link.js:47:19)  

Opening this file in VSCode I see:

    Try npm i --save-dev @types/tuyapi__link if it exists or add a new declaration (.d.ts) file containing declare module '@tuyapi/link';ts(7016)

When I run ‘npm i --save-dev @types/tuya_link’ I get:

C:\Users\user\AppData\Roaming\npm\node_modules@tuyapi\cli>npm i --save-dev @types/tuyapi_link
    npm ERR! code E404
    npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2Ftuyapi_link - Not found
    npm ERR! 404
    npm ERR! 404 ‘@types/tuyapi_link@*’ is not in the npm registry.
    npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
    npm ERR! 404
    npm ERR! 404 Note that you can also install from a
    npm ERR! 404 tarball, folder, http url, or git url.

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:\Users\user\AppData\Local\npm-cache_logs\2021-05-10T02_04_18_760Z-debug.log

In the debug log it appears to run properly up until:

2355 verbose stack HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/@types%2Ftuyapi_link - Not found
   2355 verbose stack at C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:134:15
   2355 verbose stack at processTicksAndRejections (node:internal/process/task_queues:96:5)
   2355 verbose stack at async Arborist.[nodeFromEdge] (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:947:19)
   2355 verbose stack at async Arborist.[buildDepStep] (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:893:11)
   2355 verbose stack at async Arborist.buildIdealTree (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\build-ideal-tree.js:218:7)
   2355 verbose stack at async Promise.all (index 1)
   2355 verbose stack at async Arborist.reify (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules@npmcli\arborist\lib\arborist\reify.js:135:5)
   2355 verbose stack at async Install.install (C:\Users\user\AppData\Roaming\npm\node_modules\npm\lib\install.js:137:5)
   2356 verbose statusCode 404
   2357 verbose pkgid @types/tuyapi_link@*
   2358 verbose cwd C:\Users\user\AppData\Roaming\npm\node_modules@tuyapi\cli
   2359 verbose Windows_NT 10.0.19042
   2360 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js” “i” “–save-dev” “@types/tuyapi_link”
   2361 verbose node v16.1.0
   2362 verbose npm v7.12.0
   2363 error code E404
   2364 error 404 Not Found - GET https://registry.npmjs.org/@types%2Ftuyapi_link - Not found
   2365 error 404
   2366 error 404 ‘@types/tuyapi_link@*’ is not in the npm registry.
   2367 error 404 You should bug the author to publish it (or use the name yourself!)
   2368 error 404 Note that you can also install from a
   2369 error 404 tarball, folder, http url, or git url.
   2370 verbose exit 1

Both devices are on 2.4ghz wireless. I do have pihole running via ethernet. The apps connect to the bulb and turn it from blinking to solid, but is unable to register. The cli doesn't stop it from blinking at all. I get unrecognized command when I run "DEBUG=*". I'm not sure if this is an install issue on my part or what. But the link at the end doesn't seem to be valid: https://registry.npmjs.org/@types%2Ftuyapi_link

Any input is appreciated.

@codetheweb
Copy link
Member

Sorry, it's unclear from your original post. Is the computer you're running @tuyapi/cli on connected via WiFi to your network?

The warning in VSCode doesn't matter since this package isn't written in TypeSCript (and third-party types don't exist for @tuyapi/link anyways).

@nortwood
Copy link
Author

My apologize for poor structure. Yes, I'm running tuyapi/cli on Windows 10 from a laptop connected over 2.4ghz WiFi, same as the bulb. The only device not on that WiFi is a RPi running PiHole, but it doesn't appear to be blocking anything during the attempts.

@foxylion
Copy link

foxylion commented May 16, 2021

I've a similar issue.

A week ago I connected to Smart Plugs from Teckin (SP22) via tuya-cli, it worked fine.
Today I tried to add two more smart plugs (also Teckin SP22), it did not work (same timeout error).

Windows laptop is on a 2.4 Ghz WiFi.

tuya-cli link --api-key ***** --api-secret ***** --schema ***** --ssid **-**-***** --password "*******" --region eu
- Registering devices(s)...
2021-05-16T20:04:16.056Z @tuyapi/link:wizard Token:  { region: 'EU', secret: '****', token: '*******' }
2021-05-16T20:04:16.062Z @tuyapi/link:manual Sending SmartLink initialization packets
2021-05-16T20:04:16.063Z @tuyapi/link:wizard Polling cloud for details on token...
2021-05-16T20:04:16.121Z @tuyapi/link:wizard 0 devices returned by API.
... (a lot more similar log entries) ...
2021-05-16T20:04:19.175Z @tuyapi/link:wizard 0 devices returned by API.
2021-05-16T20:04:19.215Z @tuyapi/link:manual Sending SmartLink data packets
2021-05-16T20:04:19.298Z @tuyapi/link:wizard 0 devices returned by API.
... (a lot more similar log entries) ...
2021-05-16T20:04:25.725Z @tuyapi/link:wizard 0 devices returned by API.
2021-05-16T20:04:25.794Z @tuyapi/link:manual Finished sending packets.
2021-05-16T20:04:25.799Z @tuyapi/link:wizard 0 devices returned by API.
... (a lot more similar log entries) ...
2021-05-16T20:05:17.258Z @tuyapi/link:wizard 0 devices returned by API.
�[31m�[39m Device(s) failed to be registered!
Error: Timed out waiting for devices to connect.
    at TuyaLinkWizard.linkDevice (C:\Users\jakob\AppData\Roaming\npm\node_modules\@tuyapi\cli\node_modules\@tuyapi\link\index.js:117:17)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async link (C:\Users\jakob\AppData\Roaming\npm\node_modules\@tuyapi\cli\lib\link.js:47:19)

@lesleyxyz
Copy link

lesleyxyz commented May 17, 2021

Am experiencing the same. My device worked before with the TuyaAPI, now stopped. When trying to link again it's timing out.
When I link with the official app it works perfectly. Also using Windows 10, 2.4ghz wifi

@codetheweb
Copy link
Member

Given that lots of people are suddenly having this issue, I'm guessing that either updated firmware is being rolled out or something changed with the API.

I'll try linking some of my devices later this week and see what happens.

@codetheweb
Copy link
Member

I just tried myself and it works fine for me. So I don't think the API changed and I checked in the Tuya app first to make sure there wasn't a firmware update available for my device.

I also did a quick Wireshark capture to see what the app sent during the linking process and that seems the same as well. Not really sure what's going on at this point, any additional debugging information would be helpful.

@mangusman07
Copy link

All I can say is that I have the same issue. Sylvania Smart + WiFi Bulbs. I have done all the debug steps (2.4 GHz only, wifi name only letters no spaces, unpaired from app, uninstalled app, power cycle until flashing fast) after about 4x flashing cycles the light turns solid, but I time out and can track all the same errors. Windows 8.1

@lesleyxyz
Copy link

lesleyxyz commented Oct 23, 2021

I think it has something to do with how the UDP packets are broadcasted?

I have a temporary workaround tho.

  1. Have android studio installed, or another android emulator where you can access all files.
  2. Install the recommended app for your device
  3. Link your device in your app
  4. Search /data/app/ for your device id/key

I found it but still didn't work, so I tried random IPs on my network instead of trying to search it with a broadcast and then it connected.

(I quickly wrote this, let me know if you need more details)

@mangusman07
Copy link

@lesleyxyz I'd love more details on your workaround. Ive got android studio on a windows computer. I've got the Sylvania app installed and see a paired bulb in it. Can't find the device ID in the file explorer.

Wouldn't know how to brute-force IP addresses in the pairing command to tuya.

@lesleyxyz
Copy link

Okay so once you've got the app running goto Device File Explorer and open this file:
/data/app/com.ledvance.smartplus (in the case of sylvania)

Somewhere in there, there is a file containing your key and localKey

For me it was in shared_prefs/preferences_global_keyeu_1597426102556uJkHm.xml
Then CTRL + F for localKey. It was for me in some JSON string in an XML field

Let me know again if you still can't find it, then I'll try installing that app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants