Closed ghost closed 6 years ago
As a quick fix, add "broadcasthost" with your local broadcast IP to your hosts file. Dirty, i know.
Hey, that seems to work. Now I get the following error: I am fairly new to this whole topic, I just want my python scripts to control my smart plugs. :) Thanks so much for your help!
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
I am not sure, if I configured the tuya api correctly. I got both keys but I have not configured anything else in the portal. @engelant: I am sorry, but what do you exactly mean by broadcast IP? I pointed it to 192.168.0.255 from my ifconfig.
The broadcast IP you gave is right, assuming you have the network IP 192.168.0.xxx. Are you connected via wifi? Which OS do you run? Can you provide the complete output, while using "DEBUG=* ./cli.js link-wizard"
Hey @moritzk (and anyone else who's getting this), sorry about the broadcast error. I'm pretty busy the next few days, but I'll try to look at it soon. I've only tried running @tuyapi/cli on a macOS device so far, so I'm guessing other OSes handle broadcasthost
differently.
Yesterday I bought an identical device and it worked seemlessly with the broadcasthost addition to /etc/hosts But the old device, that was registered to the app before still does not work. Do I have to debind the plug from an app? I just pressed the button until it blinked.
@engelant : Yes, I am connected to the same access point that the devices should connect to; I am running kubuntu live; @codetheweb : No worries. Thank you very much for providing your work and help. :) As stated above, the broadcasthost addition to /etc/hosts worked for the new device.
Here is the log:
root@xubuntu:/usr/local/lib/node_modules/@tuyapi/cli# DEBUG=* ./cli.js 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? LIMO ? 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 ⠋ Registering devices(s)... @tuyapi/cloud Sending parameters: +0ms @tuyapi/cloud { a: 'tuya.m.user.email.register', @tuyapi/cloud deviceId: 'u5fmfmc79maambtrxem8u97i3w5ognf7n3m6nf8gwxjn', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'j3s8ckcghyv7uvrhpfdt', @tuyapi/cloud time: 1533979441, @tuyapi/cloud postData: '{"countryCode":"AZ","email":"johndoe@example.com","passwd":"8ac4253450b2e0eccdfe0fa24036b6d5"}', @tuyapi/cloud sign: '2829c89fef14d51284813d44e7757ae0' } +0ms ⠹ Registering devices(s)... @tuyapi/cloud Received response: +1s @tuyapi/cloud {"t":1533979441965,"success":false,"errorCode":"USER_NAME_IS_EXIST","status":"error","errorMsg":"Username exists."} @tuyapi/cloud +0ms @tuyapi/cloud Sending parameters: +0ms @tuyapi/cloud { a: 'tuya.m.user.email.password.login', @tuyapi/cloud deviceId: 'u5fmfmc79maambtrxem8u97i3w5ognf7n3m6nf8gwxjn', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'j3s8ckcghyv7uvrhpfdt', @tuyapi/cloud time: 1533979442, @tuyapi/cloud postData: '{"countryCode":"AZ","email":"johndoe@example.com","passwd":"8ac4253450b2e0eccdfe0fa24036b6d5"}', @tuyapi/cloud sign: '98eeb0fdf56feba834bb941c82c23fff' } +0ms ⠴ Registering devices(s)... @tuyapi/cloud Received response: +1s @tuyapi/cloud {"result":{"timezone":"","tempUnit":1,"sid":"az153390k6585168g9yL7j53ac6f6ac7869dfd04751b649b067486de","uid":"az1533906585168gyL7j","nickname":"","phoneCode":"AZ","email":"johndoe@example.com","snsNickname":"","improveCompanyInfo":false,"dataVersion":0,"sex":0,"accountType":1,"mobile":"","headPic":"","ecode":"z5z3556a893k3z9k","domain":{"deviceHttpUrl":"http://a.tuyaus.com","deviceHttpsUrl":"https://a2.tuyaus.com","deviceMediaMqttUrl":"s.tuyaus.com","deviceMqttsUrl":"m2.tuyaus.com","gwApiUrl":"http://a.gw.tuyaus.com/gw.json","gwMqttUrl":"mq.gw.tuyaus.com","mobileApiUrl":"https://a1.tuyaus.com","mobileMediaMqttUrl":"s.tuyaus.com","mobileMqttUrl":"mq.mb.tuyaus.com","mobileMqttsUrl":"m1.tuyaus.com","pxApiUrl":"http://px.tuyaus.com","regionCode":"AZ"},"timezoneId":"","userType":1,"partnerIdentity":"p1093906","username":"johndoe@example.com"},"t":1533979442805,"success":true,"status":"ok"} @tuyapi/cloud +0ms @tuyapi/cloud Sending parameters: +1ms @tuyapi/cloud { a: 'tuya.m.device.token.create', @tuyapi/cloud deviceId: 'u5fmfmc79maambtrxem8u97i3w5ognf7n3m6nf8gwxjn', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'j3s8ckcghyv7uvrhpfdt', @tuyapi/cloud time: 1533979443, @tuyapi/cloud postData: '{"timeZone":"-05:00"}', @tuyapi/cloud sid: 'az153390k6585168g9yL7j53ac6f6ac7869dfd04751b649b067486de', @tuyapi/cloud sign: 'b75e4b1e2b554dd7425bedc60e5fa6df' } +0ms ⠹ Registering devices(s)... @tuyapi/cloud Received response: +612ms @tuyapi/cloud {"result":{"secret":"BQ1V","token":"iVcoYvuP"},"t":1533979443605,"success":true,"status":"ok"} @tuyapi/cloud +1ms @tuyapi/link:wizard Token: { secret: 'BQ1V', token: 'iVcoYvuP' } +0ms @tuyapi/link:manual Sending SmartLink initialization packets +0ms ⠋ Registering devices(s)... @tuyapi/link:manual Sending SmartLink data packets +5s ⠹ Registering devices(s)... @tuyapi/link:manual Finished sending packets. +34s @tuyapi/link:wizard Polling cloud for details on token... +39s @tuyapi/cloud Sending parameters: +39s @tuyapi/cloud { a: 'tuya.m.device.list.token', @tuyapi/cloud deviceId: 'u5fmfmc79maambtrxem8u97i3w5ognf7n3m6nf8gwxjn', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'j3s8ckcghyv7uvrhpfdt', @tuyapi/cloud time: 1533979483, @tuyapi/cloud postData: '{"token":"iVcoYvuP"}', @tuyapi/cloud sid: 'az153390k6585168g9yL7j53ac6f6ac7869dfd04751b649b067486de', @tuyapi/cloud sign: '60803281cca610f8ccf03d8f0b5e50e7' } +0ms ⠹ Registering devices(s)... @tuyapi/cloud Received response: +773ms @tuyapi/cloud {"result":[],"t":1533979483749,"success":true,"status":"ok"} @tuyapi/cloud +0ms ⠼ Registering devices(s)... @tuyapi/cloud Sending parameters: +201ms @tuyapi/cloud { a: 'tuya.m.device.list.token', @tuyapi/cloud deviceId: 'u5fmfmc79maambtrxem8u97i3w5ognf7n3m6nf8gwxjn', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'j3s8ckcghyv7uvrhpfdt', @tuyapi/cloud time: 1533979484, @tuyapi/cloud postData: '{"token":"iVcoYvuP"}', @tuyapi/cloud sid: 'az153390k6585168g9yL7j53ac6f6ac7869dfd04751b649b067486de', @tuyapi/cloud sign: '10b8b3f76b551c52e5b365ba6e3db2db' } +0ms ⠴ Registering devices(s)... @tuyapi/cloud Received response: +825ms @tuyapi/cloud {"result":[],"t":1533979484769,"success":true,"status":"ok"} @tuyapi/cloud +0ms ⠧ Registering devices(s)... @tuyapi/cloud Sending parameters: +201ms @tuyapi/cloud { a: 'tuya.m.device.list.token', @tuyapi/cloud deviceId: 'u5fmfmc79maambtrxem8u97i3w5ognf7n3m6nf8gwxjn', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'j3s8ckcghyv7uvrhpfdt', @tuyapi/cloud time: 1533979485, @tuyapi/cloud postData: '{"token":"iVcoYvuP"}', @tuyapi/cloud sid: 'az153390k6585168g9yL7j53ac6f6ac7869dfd04751b649b067486de', @tuyapi/cloud sign: 'fa5955870931e3ae719859e4c9bcc319' } +1ms ⠋ Registering devices(s)...^C
Okay, it worked also with the old one. I pressed the button for a longer time, until the led blinked faster...
Thanks so for guys. Do you want me to close this now? This is my first encounter with github! :)
Broadcast address issue is now fixed. Please update the CLI tool with npm i @tuyapi/cli@1.1.0 -g
.
@moritzk glad you got it working. I'll close the issue; but yes, in the future please close issues when your problem is solved.
Hey, thanks for your fantastic work. I get an error using tuya-cli I have no problems adding the plug with this app https://play.google.com/store/apps/details?id=com.tuya.smartlife&hl=de
✖ Device(s) failed to be registered! { Error: getaddrinfo EAI_AGAIN at Object._errnoException (util.js:1022:11) at errnoException (dns.js:55:15) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26) code: 'EAI_AGAIN', errno: 'EAI_AGAIN', syscall: 'getaddrinfo', hostname: 'broadcasthost' }