codetheweb / tuyapi

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

Device registered and Failed at the same time #505

Closed imPDA closed 1 month ago

imPDA commented 3 years ago

Hello !

Im trying to get local key for Girier smart plug, I have done everything according to description, I have even linked device via console. Is says that device is registered, and in the next string, device failed to be registerd. However it looks like this smart plug linked, it is in the list of devices on Tuya website.

1 2

What have I done wrong? API key, secret, schema double and triple cheked, it is OK. What should I do next? Thank you in advance!

codetheweb commented 3 years ago

I just recently fixed the signing error. Please update @tuyapi/cli to v1.17.2 and try again.

imPDA commented 3 years ago

Thanks for fast reply! Everything I have already done were with 1.17.2 I believe. Without update I could do nothing. Should I reinstall it from scratch? 3

codetheweb commented 3 years ago

That's odd, because in the screenshot it shows an error from OpenAPI (the old package that I replaced).

I'd try removing and reinstalling @tuyapi/cli just to make sure everything is up to date.

okrulik commented 3 years ago

Same Issue here. ✔ Device(s) registered! ✖ Device(s) failed to be registered! Error: sign invalid at OpenAPI._client.got_1.default.extend.hooks.afterResponse (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/openapi/dist/api.js:74:31) at EventEmitter.<anonymous> (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/got/dist/source/as-promise.js:87:38) at processTicksAndRejections (internal/process/task_queues.js:89:5) version is 1.17.2

codetheweb commented 3 years ago

Did you try removing and reinstalling @tuyapi/cli to make sure the sub-dependencies were updated? (Shouldn't be necessary, but again not sure what else could be going on. v0.3.4 of @tuyapi/link which @tuyapi/cli@1.17.2 depends on doesn't even reference OpenAPI as a dependency.)

@imPDA were you able to get it working?

imPDA commented 3 years ago

Unfortunately, not. Still get the same error. But it actually does something - if you compare previous output and current output:

image

And as I mentioned above, It do registered in Tuya Cloud Project after this error:

√ Device(s) registered!
× Device(s) failed to be registered!
Error: sign invalid
    at OpenAPI._client.got_1.default.extend.hooks.afterResponse (C:\Users\dimax\AppData\Roaming\npm\node_modules\@tuyapi\cli\node_modules\@tuyapi\openapi\dist\api.js:74:31)
    at EventEmitter.<anonymous> (C:\Users\dimax\AppData\Roaming\npm\node_modules\@tuyapi\cli\node_modules\got\dist\source\as-promise.js:87:38)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Cai local key be obtained only via this register process?

codetheweb commented 3 years ago

That output looks really strange as well.

Are you able to try inside a virtual machine so cached dependencies and anything else wouldn't affect it?

You can also get keys with tuya-cli wizard.

imPDA commented 3 years ago

Thank you! Tuya-cli wizard has worked as a charm. So device actually registered and this "Fail" looks like some bug - it displayed regardless of the final result.

Unfortunatelly, I have no opportunity to test it in VM at the moment.

ghost commented 2 years ago

I have the same error here. I can't use the wizard, since it needs the virtual ID of a device, and I'm trying to configure my first device.

codetheweb commented 2 years ago

@galvaof

All devices that you want to use must be registered in either the Tuya Smart app or the Smart Life app.