codetheweb / tuyapi

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

Device(s) Failed to be registered! #69

Closed legolass73 closed 5 years ago

legolass73 commented 6 years ago

I've created the Tuya account and obtained the ID and Key from the site.

When I go to add a device I get the following error. 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) at

the wizard is on a Docker environment with oznu homebridge and its homebridge-config-ui-x installed via its homebridge-syno-spk package on my nas synology ds218+

I'm using this smart plug "https://www.amazon.fr/gp/product/B07BKY4QFV/ref=oh_aui_detailpage_o07_s00?ie=UTF8&psc=1" with the Smart Life app.

I put the switch in pairing mode but the wizard never finds it. Instantly can add it back to the Smart Life app though.

I use the iOS APP KEY from Tuya for apikey in the wizard and iOS APP Secret from Tuya for apisecret in the wizard. Am I doing something wrong?

I am French and quite bad in English, excuse me in advance for errors in pronunciation, spelling, grammar and especially comprehension.

codetheweb commented 6 years ago

Everything sounds right...

Do you ever hear your plug "click" when you run my pairing wizard?

EDIT: Actually, I just realized that since you're in France Tuya might be expecting you to use a different server than the default U.S. one. I'll look into it on Monday.

legolass73 commented 6 years ago

yes, I heard a "click" when the plug is in pairing mode

can we change the server manually if not?

apologize for the close and reopening of the issue, I unintentionally clicked on my phone while I was translating your message

codetheweb commented 6 years ago

See my comment here on changing the region. I'm not sure if this is the issue yet, but try it out and see if it works.

legolass73 commented 6 years ago

okay, I'll let you know if it works

legolass73 commented 6 years ago

I give you the result of the link?

codetheweb commented 6 years ago

Yes please.

legolass73 commented 6 years ago

I have to try pairing the plug with the link?

legolass73 commented 6 years ago

root@orion:/homebridge/link# DEBUG=* node dev.js module.js:549 throw err; ^

Error: Cannot find module '@tuyapi/cloud' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (/homebridge/link/index.js:1:77) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) root@orion:/homebridge/link#

legolass73 commented 6 years ago

root@orion:/homebridge/link# DEBUG=* node dev.js @tuyapi/cloud Sending parameters: +0ms @tuyapi/cloud { a: 'tuya.m.user.email.register', @tuyapi/cloud deviceId: '0dclmz2gzetg4ir5t37k3f20zewnl98yliii2t14awe8', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'gwep8d8enugjvvcek45d', @tuyapi/cloud time: 1534847377, @tuyapi/cloud postData: '{"countryCode":"EU","email":"**.**@gmail.com","passwd":"a458c09dcd96bc0552817e83d30e8529"}', @tuyapi/cloud sign: 'd38c7f27682118a2a375c9793b350993' } +6ms @tuyapi/cloud Received response: +675ms @tuyapi/cloud {"t":1534847381300,"success":false,"errorCode":"USER_NAME_IS_EXIST","status":"error","errorMsg":"Username exists."} @tuyapi/cloud +0ms @tuyapi/cloud Sending parameters: +2ms @tuyapi/cloud { a: 'tuya.m.user.email.password.login', @tuyapi/cloud deviceId: '0dclmz2gzetg4ir5t37k3f20zewnl98yliii2t14awe8', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'gwep8d8enugjvvcek45d', @tuyapi/cloud time: 1534847378, @tuyapi/cloud postData: '{"countryCode":"EU","email":"**.**@gmail.com","passwd":"a458c09dcd96bc0552817e83d30e8529"}', @tuyapi/cloud sign: 'b8b2d3c405ac8f9108063de675b258b7' } +1ms @tuyapi/cloud Received response: +1s @tuyapi/cloud {"result":{"dataVersion":0,"timezone":"","sex":0,"accountType":1,"tempUnit":1,"mobile":"","headPic":"","sid":"az153484252168453mPUChS3a44ec2d5fe2e7cee8386ed5b5fe08507","ecode":"z2z45323141z8234","uid":"az15348452168453PUCh","domain":{"gwApiUrl":"http://a.gw.tuyaus.com/gw.json","mobileApiUrl":"https://a1.tuyaus.com","regionCode":"AZ","deviceHttpUrl":"http://a.tuyaus.com","mobileMqttUrl":"mq.mb.tuyaus.com","deviceMediaMqttUrl":"s.tuyaus.com","pxApiUrl":"http://px.tuyaus.com","deviceHttpsUrl":"https://a2.tuyaus.com","deviceMqttsUrl":"m2.tuyaus.com","gwMqttUrl":"mq.gw.tuyaus.com","mobileMediaMqttUrl":"s.tuyaus.com","mobileMqttsUrl":"m1.tuyaus.com"},"nickname":"","phoneCode":"EU","timezoneId":"","userType":1,"partnerIdentity":"p1096919","email":"******.******@gmail.com","snsNickname":"","improveCompanyInfo":false,"username":"******.******@gmail.com"},"t":1534847382324,"success":true,"status":"ok"} @tuyapi/cloud +0ms @tuyapi/cloud Sending parameters: +2ms @tuyapi/cloud { a: 'tuya.m.device.token.create', @tuyapi/cloud deviceId: '0dclmz2gzetg4ir5t37k3f20zewnl98yliii2t14awe8', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'gwep8d8enugjvvcek45d', @tuyapi/cloud time: 1534847379, @tuyapi/cloud postData: '{"timeZone":"-05:00"}', @tuyapi/cloud sid: 'az153484252168453mPUChS3a44ec2d5fe2e7cee8386ed5b5fe08507', @tuyapi/cloud sign: '9beec93c6e3aa47043090b48ad9b6cb0' } +1ms @tuyapi/cloud Received response: +270ms @tuyapi/cloud {"t":1534847382681,"success":false,"errorCode":"USER_SESSION_INVALID","status":"error","errorMsg":"Session Expired, please log in again"} @tuyapi/cloud +0ms (node:876) UnhandledPromiseRejectionWarning: # (node:876) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was nothandled with .catch(). (rejection id: 1) (node:876) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

legolass73 commented 6 years ago

root@orion:/homebridge/link# DEBUG=* node dev.js @tuyapi/cloud Sending parameters: +0ms @tuyapi/cloud { a: 'tuya.m.user.email.register', @tuyapi/cloud deviceId: '78iwr2j2ry3c5p7ecytgraustuvtpf097pakxruu5yuo', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'gwep8d8enugjvvcek45d', @tuyapi/cloud time: 1534851998, @tuyapi/cloud postData: '{"countryCode":"EU","email":"legolass73@live.fr","passwd":"532d973bf3cb17b8800d7f6787d3888c"}', @tuyapi/cloud sign: 'd2f3551c7f9eb22b6859d77f6a84074c' } +4ms @tuyapi/cloud Received response: +918ms @tuyapi/cloud {"result":{"dataVersion":0,"sex":0,"tempUnit":1,"headPic":"","sid":"az153485W2002436wt0BfMH395497bd85cc646466110aa82ea222583","ecode":"z0z453W451aa1358","uid":"az1534852002436w0BfM","domain":{"gwApiUrl":"http://a.gw.tuyaus.com/gw.json","mobileApiUrl":"https://a1.tuyaus.com","regionCode":"AZ","deviceHttpUrl":"http://a.tuyaus.com","mobileMqttUrl":"mq.mb.tuyaus.com","deviceMediaMqttUrl":"s.tuyaus.com","pxApiUrl":"http://px.tuyaus.com","deviceHttpsUrl":"https://a2.tuyaus.com","deviceMqttsUrl":"m2.tuyaus.com","gwMqttUrl":"mq.gw.tuyaus.com","mobileMediaMqttUrl":"s.tuyaus.com","mobileMqttsUrl":"m1.tuyaus.com"},"nickname":"","phoneCode":"EU","timezoneId":"","userType":1,"partnerIdentity":"p1096919","email":"legolass73@live.fr","snsNickname":"","improveCompanyInfo":false,"username":"legolass73@live.fr"},"t":1534852002495,"success":true,"status":"ok"} @tuyapi/cloud +0ms @tuyapi/cloud Sending parameters: +2ms @tuyapi/cloud { a: 'tuya.m.device.token.create', @tuyapi/cloud deviceId: '78iwr2j2ry3c5p7ecytgraustuvtpf097pakxruu5yuo', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'gwep8d8enugjvvcek45d', @tuyapi/cloud time: 1534851999, @tuyapi/cloud postData: '{"timeZone":"-05:00"}', @tuyapi/cloud sid: 'az153485W2002436wt0BfMH395497bd85cc646466110aa82ea222583', @tuyapi/cloud sign: '82f36c3dbb66e6e17c49dfeddbe30097' } +0ms @tuyapi/cloud Received response: +276ms @tuyapi/cloud {"t":1534852002871,"success":false,"errorCode":"USER_SESSION_INVALID","status":"error","errorMsg":"Session Expired, please log in again"} @tuyapi/cloud +0ms (node:886) UnhandledPromiseRejectionWarning: # (node:886) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was nothandled with .catch(). (rejection id: 1) (node:886) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

legolass73 commented 6 years ago

were you able to look around and find the problem?

legolass73 commented 6 years ago

I put two more or less the same message but one came from my pc under windows with terminal "babun" and cmd and the second came from the docker linux or homebridge, I tested on both system in case or one of them have a problem but it had put both the same mistake

codetheweb commented 6 years ago

Ok.

It looks like your region might not be the issue. Are you able to sniff the traffic of your phone with Charles? Instructions are here. I want to see if the official apps are changing their parameters based on region or not.

legolass73 commented 6 years ago

I don't know how to do it, I installed and launch charles on my iphone but after I don't know what to do

legolass73 commented 6 years ago

I tried to follow up by adapting the tuto to add the plug with the charles proxy on my iphone but unfortunately, the plug doesn't want to be added with the app when charles is active

legolass73 commented 6 years ago

yes

codetheweb commented 5 years ago

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

codetheweb commented 5 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?

codetheweb commented 5 years ago

Have you tried again recently? Any update?