Giter VIP home page Giter VIP logo

Comments (102)

S-K-Lieren avatar S-K-Lieren commented on May 24, 2024 2

@Apollon7:

You might want to anonymize the data you posted. Your home address is visible to the public.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024 1

Good news: I recently purchased (yet another) smart plug, but this one isn't working with my linking code. I finally have a device on my hands that I can use to debug why it isn't working for some people. I'm currently experimenting with registering it in AP mode, so we'll see what happens.

@Apollon77 the AZ region shouldn't matter, that sounds fine. (AZ is just the default region in my module, and according to survey results it does work for people in the EU with the default settings.)

from tuyapi.

S-K-Lieren avatar S-K-Lieren commented on May 24, 2024 1

@Apollon77 There are still latitude and longitude values in your data 😝

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@rbyers8252 everything sounds good...

I'm not sure what shell you're using on Windows, but can you please set the environment variable DEBUG to *, run the linking wizard again, and post the output?

from tuyapi.

S-K-Lieren avatar S-K-Lieren commented on May 24, 2024

Very strangely, setting the environment var DEBUG to * already did the trick for me.

from tuyapi.

rbyers8252 avatar rbyers8252 commented on May 24, 2024

Not an expert with all of this. Been a long time since I did a bunch of this. How do I set the environment var debug to * ?

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

I managed to find it for windows cmd SET DEBUG=*
or $env:DEBUG = "*" for powershell
I have the same error and I got a minute of this.

`- Registering devices(s)... @tuyapi/cloud Sending parameters: +202ms
@tuyapi/cloud { a: 'tuya.m.device.list.token',
@tuyapi/cloud deviceId: '6kkpgqusqcttueoa3502kj6vujbd0pya64u7t7l3k5h4',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'my ios app key',
@tuyapi/cloud time: 1534504445,
@tuyapi/cloud postData: '{"token":"cWW0KWZt"}',
@tuyapi/cloud sid: 'az15344262526951vjKzyby31f70b89116d7c63518372b15a642803f',
@tuyapi/cloud sign: 'dd7454007571175f79633aa0766a611f' } +3ms

  • Registering devices(s)... @tuyapi/cloud Received response: +530ms
    @tuyapi/cloud {"result":[],"t":1534504449201,"success":true,"status":"ok"}
    @tuyapi/cloud +5ms
    | Registering devices(s)... @tuyapi/cloud Sending parameters: +204ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '6kkpgqusqcttueoa3502kj6vujbd0pya64u7t7l3k5h4',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'my ios app key',
    @tuyapi/cloud time: 1534504446,
    @tuyapi/cloud postData: '{"token":"cWW0KWZt"}',
    @tuyapi/cloud sid: 'az15344262526951vjKzyby31f70b89116d7c63518372b15a642803f',
    @tuyapi/cloud sign: '02154a22499d79e19e792893c72d6068' } +5ms
    | Registering devices(s)... @tuyapi/cloud Received response: +489ms
    @tuyapi/cloud {"result":[],"t":1534504449907,"success":true,"status":"ok"}
    @tuyapi/cloud +5ms
    / Registering devices(s)... @tuyapi/cloud Sending parameters: +203ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '6kkpgqusqcttueoa3502kj6vujbd0pya64u7t7l3k5h4',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'my ios app key',
    @tuyapi/cloud time: 1534504447,
    @tuyapi/cloud postData: '{"token":"cWW0KWZt"}',
    @tuyapi/cloud sid: 'az15344262526951vjKzyby31f70b89116d7c63518372b15a642803f',
    @tuyapi/cloud sign: '605009dd21ab4e4e29f1419266edfe2d' } +2ms
    / Registering devices(s)... @tuyapi/cloud Received response: +533ms
    @tuyapi/cloud {"result":[],"t":1534504450647,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    × Device(s) failed to be registered!
    Error: Timed out wating for device(s) to connect to cloud
    at Promise (C:\Users\Stephen\AppData\Roaming\npm\node_modules@tuyapi\cli\node_modules@tuyapi\cloud\index.js:275:12)
    at `

with no registration

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

If I register it through the app is it the

@tuyapi/cloud deviceId: '6kkpgqusqcttueoa3502kj6vujbd0pya64u7t7l3k5h4',
that I need to use the API?

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@BenjaminKauer if possible, could you run a few tests and see if setting DEBUG=* is the only reason it worked? If so, that's a rather strange bug that needs to be fixed.

@stephenmhall what's your configuration? Does the computer you're running the tool from have a (enabled) wireless card?

Sometimes devices get "stuck", and unplugging then plugging them back in seems to help.

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

@stephenmhall what's your configuration? Does the computer you're running the tool from have a (enabled) wireless card?

Ok can I assume from this my PC has to be on the wifi not lan? Now I think about it of course it needs a wifi connection as it will need to connect to the plug before it gets placed on my network. Sorry fundamental misunderstanding from me there. I have wifi but disabled, I will have another go.

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

well, a lot of it looks to be working but it never registers.

`- Registering devices(s)... @tuyapi/cloud Sending parameters: +0ms
@tuyapi/cloud { a: 'tuya.m.user.email.register',
@tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'myID',
@tuyapi/cloud time: 1534584771,
@tuyapi/cloud postData: '{"countryCode":"AZ","email":"[email protected]","passwd":"8ac4253450b2e0eccdfe0fa24036b6d5"}',
@tuyapi/cloud sign: 'ae425b03f88f2fadf1fa6015d14aa676' } +2ms
| Registering devices(s)... @tuyapi/cloud Received response: +858ms
@tuyapi/cloud {"t":1534584773312,"success":false,"errorCode":"USER_NAME_IS_EXIST","status":"error","errorMsg":"Username exists."}
@tuyapi/cloud +4ms
@tuyapi/cloud Sending parameters: +3ms
@tuyapi/cloud { a: 'tuya.m.user.email.password.login',
@tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'myID',
@tuyapi/cloud time: 1534584772,
@tuyapi/cloud postData: '{"countryCode":"AZ","email":"[email protected]","passwd":"8ac4253450b2e0eccdfe0fa24036b6d5"}',
@tuyapi/cloud sign: '0e79cffff18b546803ceec5c6c2e57e9' } +1ms
| Registering devices(s)... @tuyapi/cloud Received response: +578ms
@tuyapi/cloud {"result":{"timezone":"","tempUnit":1,"sid":"az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5","uid":"az1534422526951vKzyb","nickname":"","phoneCode":"AZ","email":"[email protected]","snsNickname":"","improveCompanyInfo":false,"dataVersion":0,"sex":0,"accountType":1,"mobile":"","headPic":"","ecode":"z5z453311141424z","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":"p1095947","username":"[email protected]"},"t":1534584773911,"success":true,"status":"ok"}
@tuyapi/cloud +4ms
@tuyapi/cloud Sending parameters: +3ms
@tuyapi/cloud { a: 'tuya.m.device.token.create',
@tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'myID',
@tuyapi/cloud time: 1534584773,
@tuyapi/cloud postData: '{"timeZone":"-05:00"}',
@tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
@tuyapi/cloud sign: 'd8af7efbc00f1722c04fe150e0ece126' } +1ms
/ Registering devices(s)... @tuyapi/cloud Received response: +547ms
@tuyapi/cloud {"result":{"secret":"WU1C","token":"M4byJnXr"},"t":1534584774466,"success":true,"status":"ok"}
@tuyapi/cloud +1ms
@tuyapi/link:wizard Token: { secret: 'WU1C', token: 'M4byJnXr' } +0ms
@tuyapi/link:manual Sending SmartLink initialization packets +0ms
@tuyapi/link:wizard Polling cloud for details on token... +5ms
@tuyapi/cloud Sending parameters: +12ms
@tuyapi/cloud { a: 'tuya.m.device.list.token',
@tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'myID',
@tuyapi/cloud time: 1534584773,
@tuyapi/cloud postData: '{"token":"M4byJnXr"}',
@tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
@tuyapi/cloud sign: 'ae16b8a5a59f20c9787b0e1a7785aa86' } +1ms
/ Registering devices(s)... @tuyapi/cloud Received response: +544ms
@tuyapi/cloud {"result":[],"t":1534584775017,"success":true,"status":"ok"}
@tuyapi/cloud +4ms

  • Registering devices(s)... @tuyapi/cloud Sending parameters: +203ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584774,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: '6a68734d6e61cf5caee959cd7123dccc' } +4ms
  • Registering devices(s)... @tuyapi/cloud Received response: +526ms
    @tuyapi/cloud {"result":[],"t":1534584775761,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    | Registering devices(s)... @tuyapi/cloud Sending parameters: +205ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584775,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: '2e2059d4bf06cf422beb8eaa205c1644' } +4ms
    | Registering devices(s)... @tuyapi/cloud Received response: +526ms
    @tuyapi/cloud {"result":[],"t":1534584776498,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
  • Registering devices(s)... @tuyapi/cloud Sending parameters: +203ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584775,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: '2e2059d4bf06cf422beb8eaa205c1644' } +2ms
  • Registering devices(s)... @tuyapi/cloud Received response: +629ms
    @tuyapi/cloud {"result":[],"t":1534584777333,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    | Registering devices(s)... @tuyapi/cloud Sending parameters: +201ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584776,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: 'b476c9b141cfcf5c501574df30eb87db' } +4ms
    | Registering devices(s)... @tuyapi/cloud Received response: +525ms
    @tuyapi/cloud {"result":[],"t":1534584778075,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    / Registering devices(s)... @tuyapi/cloud Sending parameters: +202ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584777,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: '8c62542333578bd8c5894327af0e380e' } +4ms
    / Registering devices(s)... @tuyapi/cloud Received response: +500ms
    @tuyapi/cloud {"result":[],"t":1534584778790,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    \ Registering devices(s)... @tuyapi/cloud Sending parameters: +203ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584778,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: 'd45ac6915e5ae6529e191eb62b9b42eb' } +4ms
    \ Registering devices(s)... @tuyapi/cloud Received response: +541ms
    @tuyapi/cloud {"result":[],"t":1534584779529,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    / Registering devices(s)... @tuyapi/cloud Sending parameters: +203ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584778,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: 'd45ac6915e5ae6529e191eb62b9b42eb' } +2ms
  • Registering devices(s)... @tuyapi/link:manual Sending SmartLink data packets +5s
    / Registering devices(s)... @tuyapi/cloud Received response: +592ms
    @tuyapi/cloud {"result":[],"t":1534584780333,"success":true,"status":"ok"}
    @tuyapi/cloud +4ms
    \ Registering devices(s)... @tuyapi/cloud Sending parameters: +201ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584779,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: 'd979424725ed612765e9f2f9e3f75783' } +2ms`

Then what looks to be 37 seconds later.

`| Registering devices(s)... @tuyapi/cloud Received response: +591ms
@tuyapi/cloud {"result":[],"t":1534584817699,"success":true,"status":"ok"}
@tuyapi/cloud +4ms
/ Registering devices(s)... @tuyapi/link:manual Finished sending packets. +38s

  • Registering devices(s)... @tuyapi/cloud Sending parameters: +206ms
    @tuyapi/cloud { a: 'tuya.m.device.list.token',
    @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht',
    @tuyapi/cloud os: 'Linux',
    @tuyapi/cloud lang: 'en',
    @tuyapi/cloud v: '1.0',
    @tuyapi/cloud clientId: 'myID',
    @tuyapi/cloud time: 1534584817,
    @tuyapi/cloud postData: '{"token":"M4byJnXr"}',
    @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5',
    @tuyapi/cloud sign: '22915bddd1057fe029e9af2eae623397' } +3ms
    / Registering devices(s)... @tuyapi/cloud Received response: +523ms
    @tuyapi/cloud {"result":[],"t":1534584818428,"success":true,"status":"ok"}
    @tuyapi/cloud +6ms`

Then the same lines over and over for another 107 seconds until, sorry couldnt get the next block to format.

| Registering devices(s)... @tuyapi/cloud Sending parameters: +204ms @tuyapi/cloud { a: 'tuya.m.device.list.token', @tuyapi/cloud deviceId: '5fpd9gbt61dgwr5vz2y70xcj5xuj3e0xdqt5vqtnawht', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 'myID', @tuyapi/cloud time: 1534584924, @tuyapi/cloud postData: '{"token":"M4byJnXr"}', @tuyapi/cloud sid: 'az153442r2526951vxKzybb3e55dda0f3008986a3d2e77ca1881d5b5', @tuyapi/cloud sign: '2217ac6a22004d3e69a19495f69635a2' } +4ms | Registering devices(s)... @tuyapi/cloud Received response: +500ms @tuyapi/cloud {"result":[],"t":1534584925516,"success":true,"status":"ok"} @tuyapi/cloud +4ms Device(s) failed to be registered! Error: Timed out wating for device(s) to connect to cloud at Promise (C:\Users\Stephen\AppData\Roaming\npm\node_modules\@tuyapi\cli\node_modules\@tuyapi\cloud\index.js:275:12) at <anonymous>

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

After all this it might be a faulty unit. I can't register it using the Smart Life app either. Came as a pair and the first one registered fine on the app.

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

I got this after 116 seconds trying the pre registered one. It did however remove it from the app. It was re discovered by the app ok.

× Device(s) failed to be registered! { HTTPError: Response code 400 (Bad Request) at stream.catch.then.data (C:\Users\Stephen\AppData\Roaming\npm\node_modules\@tuyapi\cli\node_modules\got\index.js:386:13) at <anonymous> at process._tickCallback (internal/process/next_tick.js:118:7) name: 'HTTPError', host: 'a1.tuyaus.com', hostname: 'a1.tuyaus.com', method: 'GET', path: '/api.json?a=tuya.m.device.list.token&deviceId=t4kisxbdd4jxf7vyt74qgg3qa3ba56ywjho27ozwon46&os=Linux&lang=en&v=1.0&clientId=n87gvu8wapamy9jyqp3q&time=1534592956&postData=%7B%22token%22%3A%22c5eWa3yj%22%7D&sid=az153442l2526951vHKzybK31984620d3bcd8f72b8b93b3e0a771f1d&sign=f63352d342c8e96250e79c709a5f20a1', protocol: 'https:', url: 'https://a1.tuyaus.com/api.json', statusCode: 400, statusMessage: 'Bad Request', headers: { date: 'Sat, 18 Aug 2018 11:49:17 GMT', server: 'Apache-Coyote/1.1', 'content-length': '0', connection: 'Close' } }

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@stephenmhall are you in the U.S.? If not, your issue may stem from Tuya wanting you to use a different endpoint/server than the default. I just realized this in a different issue.

from tuyapi.

stephenmhall avatar stephenmhall commented on May 24, 2024

No I'm in the UK. So I presume I need to edit some of the default details in tuya-cli? I see the endpoints are coded into the cloud/index.js file, does the link-wizard need some extra code to select endpoint when registering.

from tuyapi.

lanceuppercut47 avatar lanceuppercut47 commented on May 24, 2024

I'm also having a similar problem and am in the UK, I am able to use the Tuya app on my phone to register it without issue but I get this when trying to do it this way:

Matts-MacBook-Pro:~ matt$ 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? WIFI1111
? 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 (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/cloud/index.js:275:12)

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

For those in the UK: try the instructions below to see if the error is related to your region.

  1. Clone @tuyapi/link by running git clone https://github.com/TuyaAPI/link.git or downloading a zipped version of the master branch from Github.
  2. Move to the new directory (cd link on *nix) and create a new file called dev.js with the contents below:
const TuyaLink = require('./index.js');

const register = new TuyaLink.wizard({apiKey: '<your-api-key>',
                                      apiSecret: '<your-api-secret>',
                                      email: '[email protected]', password: 'example-password',
                                      region: 'EU'});

register.init().then(sid => {
  register.linkDevice({ssid: '<your-ssid>', wifiPassword: '<your-wifi-password>'}).then(devices => {
  	console.log(devices)
  });

}).catch(err => {
  console.log(err)
});
  1. Replace the <*> placeholders with the appropriate values (the email and password parameters don't really matter).

  2. Run npm i to install dependencies.

  3. Run DEBUG=* node dev.js and paste the results.

from tuyapi.

amitn16 avatar amitn16 commented on May 24, 2024

Hi Team,

I am also facing similar issue, while running "tuya-cli link-wizard". It is throwing error in registering the plug with timeout error message.

I

bought plugs from China and it works well with Smart Life app and I am using these plugs in Norway..later it would be used in India also :).

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)

from tuyapi.

codehearts avatar codehearts commented on May 24, 2024

I'm experiencing the same issue in the states, I attempt to register but it times out waiting for it to connect to the cloud. I have this Tonbux power strip but haven't tried setting it up with an app (I was hoping to avoid that)

DEBUG=* didn't seem to change anything, I get the same repeated lines detailed above.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Has anyone in this thread:

  • Resolved their issue?
  • Tried using the EU-region code above?
  • Got it working without changing anything?

from tuyapi.

mafu-mac avatar mafu-mac commented on May 24, 2024

I was getting the same timeout problem trying to register my bulb from a Raspberry Pi here in the UK.
Many thanks for posting the code above - now says it's registered fine.

from tuyapi.

codehearts avatar codehearts commented on May 24, 2024

I tried registering my device three times (the third time I unplugged and plugged the device back in while the link wizard ran), didn't work. I then tried with DEBUG=* and it worked for me 🤷‍♀️

from tuyapi.

the-swissionary avatar the-swissionary commented on May 24, 2024

Hello,
Sadly, I was not that successful.
I too am getting the "timeout waiting for device(s)" message.
I did try pasting the code into dev.js
Sadly, this one almost instantly fails with an error, saying my session had expired. As I copy-pasted all the necessary items, I don't think I made a typo.
These are the last lines appearing in the debug:
@tuyapi/cloud { a: 'tuya.m.device.token.create',
@tuyapi/cloud deviceId: 'emcg84ujrzo19pltd1x7yxwoo2fe9wnn87o0cggzrems',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'p8fcw87cepukt98u5rnh',
@tuyapi/cloud time: 1535828794,
@tuyapi/cloud postData: '{"timeZone":"-05:00"}',
@tuyapi/cloud sid: 'az153582M80686451rLRjro3c47a810b55d3f0b46e342acd89f9dd1e
',
@tuyapi/cloud sign: 'cff1f48e5e76b7ce51a90fa5aada5285' } +1ms
@tuyapi/cloud Received response: +218ms
@tuyapi/cloud {"t":1535828794017,"success":false,"errorCode":"USER_SESSION_INV
ALID","status":"error","errorMsg":"Session Expired, please log in again"}

Is there anything I can try / check?
I am in Switzerland, so I guess EU as a region is correct.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Besides the region parameter, the other one that might affect stuff is the timezone.

@the-swissionary @amitn16 @lanceuppercut47 @stephenmhall

Try adjusting the timezone parameter in the below code with your UTC offset and see if it works:

const TuyaLink = require('./index.js');

const register = new TuyaLink.wizard({apiKey: '<your-api-key>',
                                      apiSecret: '<your-api-secret>',
                                      timezone: '-05:00',
                                      email: '[email protected]', password: 'example-password',
                                      region: 'EU'});

register.init().then(sid => {
  register.linkDevice({ssid: '<your-ssid>', wifiPassword: '<your-wifi-password>'}).then(devices => {
  	console.log(devices)
  });

}).catch(err => {
  console.log(err)
});

from tuyapi.

codehearts avatar codehearts commented on May 24, 2024

I've been able to register the device twice, but it takes a few hours of trying to connect. I tried changing the timezone but it's just as finicky. The default region should be ok since I'm in the US.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Huh. I'm really confused because it works flawlessly for me every single time.

from tuyapi.

the-swissionary avatar the-swissionary commented on May 24, 2024

Well, I tried the new code you sent me (try to reply to your message via email, but somehow, my reply must have gotten stuck).
Sadly, adjusting the time zone to "02:00" and to "01:002 alone did not fix the "session expoired" error.
However, I experimentally tried to change the region code to "AZ" - because in the debug log, I saw that one been returned by what I guess was the tuya server.
Setting the region code to "AZ" at least does not give me the "session expired" message anymore, and the dev.js script runs perfectly.
Sadly, it still would not recognize or register my device. :-(
Mostly, the debug log shows this in repeat:
@tuyapi/cloud Sending parameters: +205ms
@tuyapi/cloud { a: 'tuya.m.device.list.token',
@tuyapi/cloud deviceId: 'd6pxx9dleh9ky0sivwy559v6mpchfr1axlhzgxzcio38',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: 'p8fcw87cepukt98u5rnh',
@tuyapi/cloud time: 1535832118,
@tuyapi/cloud postData: '{"token":"sjz1FO1p"}',
@tuyapi/cloud sid: 'az153574f0632470K9iQHQM39ef18d02eb85dfa875fd1dc7404d51f6
',
@tuyapi/cloud sign: 'd81405b15dce2e4d3db93fe3172977e2' } +0ms
@tuyapi/cloud Received response: +610ms
@tuyapi/cloud {"result":[],"t":1535832118572,"success":true,"status":"ok"}
@tuyapi/cloud +0ms
@tuyapi/cloud Sending parameters: +207ms
...
and so on.
What I don't see in the debug at all any sign of tuya-cli trying to somehow scan my wlan for a tuya device.
This makes me wonder: Is there anything I have to configure in my wlan settings?
curently, the raspberry pi connects to my network using its built-in wlan adapter.
Is that ok? Or does the wlan adapter have to remain not connected?

from tuyapi.

chsims1 avatar chsims1 commented on May 24, 2024

No joy here in UK. Tried EU region code:

@tuyapi/cloud Sending parameters: +0ms
@tuyapi/cloud { a: 'tuya.m.user.email.register',
@tuyapi/cloud deviceId: '5cf84u0il716lsutflgtb6wjk40r8xwdq18n3s65si4w',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: '',
@tuyapi/cloud time: 1535886159,
@tuyapi/cloud postData:
@tuyapi/cloud '{"countryCode":"EU","email":"[email protected]","passwd":"cc4436eff149ba9761aaac07b36360ea"}',
@tuyapi/cloud sign: '2aa222ade568b747f1d0e49d9d2eb85a' } +1ms
@tuyapi/cloud Received response: +529ms
@tuyapi/cloud {"t":1535886159131,"success":false,"errorCode":"USER_NAME_IS_EXIST","status":"error","errorMsg":"Username exists."}
@tuyapi/cloud +0ms
@tuyapi/cloud Sending parameters: +1ms
@tuyapi/cloud { a: 'tuya.m.user.email.password.login',
@tuyapi/cloud deviceId: '5cf84u0il716lsutflgtb6wjk40r8xwdq18n3s65si4w',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: '
',
@tuyapi/cloud time: 1535886159,
@tuyapi/cloud postData:
@tuyapi/cloud '{"countryCode":"EU","email":"[email protected]","passwd":"cc4436eff149ba9761aaac07b36360ea"}',
@tuyapi/cloud sign: 'b35d6b5cc1fbb64c1f6e77d6a9779dfc' } +0ms
@tuyapi/cloud Received response: +916ms
@tuyapi/cloud {"result":{"dataVersion":0,"timezone":"","sex":0,"accountType":1,"tempUnit":1,"mobile":"","headPic":"","sid":"az153588y5226667Csa4XsJ3e7e236f98de40c9e36a5b2d673afb8a5","ecode":"z2z555yy55118888","uid":"az1535885226667Ca4Xs","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":"p1107934","email":"[email protected]","snsNickname":"","improveCompanyInfo":false,"username":"[email protected]"},"t":1535886160059,"success":true,"status":"ok"}
@tuyapi/cloud +0ms
@tuyapi/cloud Sending parameters: +2ms
@tuyapi/cloud { a: 'tuya.m.device.token.create',
@tuyapi/cloud deviceId: '5cf84u0il716lsutflgtb6wjk40r8xwdq18n3s65si4w',
@tuyapi/cloud os: 'Linux',
@tuyapi/cloud lang: 'en',
@tuyapi/cloud v: '1.0',
@tuyapi/cloud clientId: '
**************',
@tuyapi/cloud time: 1535886160,
@tuyapi/cloud postData: '{"timeZone":"+01:00"}',
@tuyapi/cloud sid: 'az153588y5226667Csa4XsJ3e7e236f98de40c9e36a5b2d673afb8a5',
@tuyapi/cloud sign: 'b5193a4f047e03944825ba398e765148' } +0ms
@tuyapi/cloud Received response: +136ms
@tuyapi/cloud {"t":1535886160283,"success":false,"errorCode":"USER_SESSION_INVALID","status":"error","errorMsg":"Session Expired, please log in again"}

Adding timezone didn't work either.

from tuyapi.

amitn16 avatar amitn16 commented on May 24, 2024

I am able to do that for tuyaapi but not able to integrate with openhab.
follow following..
install npm & timeout.. follow the procedure given in below link. ( cleanup would be good ) and then install tuyaapi.

cd /etc/openhab2/scripts
npm install codetheweb/tuyapi

https://github.com/unparagoned/njsTuya/blob/master/README.md

local key you have to find using capture packet. ( capture logs while connecting smart plug 1st time iwth Smartlife or any other similar app)
other details you can get by running > python njstuyamonitor.py >

you would able to control switch through command line using it.. but openhab integration.. I am still struggling.. any clue..

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@the-swissionary the state of your WiFi adapter shouldn't matter as long as it's enabled; the setup process works by broadcasting a series of UDP packets that are sniffed by Tuya devices.

For those who are still struggling to get it to work: do you hear your device "click" during an unsuccessful setup?

from tuyapi.

lanceuppercut47 avatar lanceuppercut47 commented on May 24, 2024

Mine doesn't click but I've given up using this new one until it's fixed, the old one works fine now that I know to assign an IP in the config.json

from tuyapi.

the-swissionary avatar the-swissionary commented on May 24, 2024

No, there's no click from my device either.

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

Hi, I am also in the UK and am having similar issues - I am on a Rasberry Pi, with a working homebridge set up controlling other platforms and accessories. My Pi is connected via ethernet, not wifi.

I used the dev.js file as suggested, got the session expired error and then tried the region AZ as suggested by @the-swissionary. This got the code working, but my devices never register. I can immediately register the same device with the Tuya app, so there's no issue there.

Thanks,
Richard

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@dickieblack are you able to run the linking wizard from a device that has a WiFi radio?

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

Hi, the Pi I am using does have Wi-Fi built in - its a model 3B. However, as it’s using the Ethernet connection it may not be active. Does it need to be connected via Wi-Fi for the link wizard to work?

from tuyapi.

denzel1994 avatar denzel1994 commented on May 24, 2024

I am using the following powerstrip by Meross https://www.amazon.de/Steckdosenleiste-Mehrfachsteckdose-Überspannungsschutz-Intelligenten-USB-Anschlüsse/dp/B079DNZP4T/ref=sr_1_1_sspa?ie=UTF8&qid=1535976878&sr=8-1-spons&keywords=meross+steckdosenleiste&psc=1.

It does not use the Smart Life App, but instead their own Meross App.
So I am not quite sure if it even works with Tuya Cloud. I didn't have any luck the first try.
Also got the following output:
✖ Device(s) failed to be registered! Error: Timed out wating for device(s) to connect to cloud at Promise (/usr/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/cloud/index.js:275:12) at <anonymous>

I applied the fixes to TuyaLink. Got the following output:
DEBUG=* node dev.js @tuyapi/cloud Sending parameters: +0ms @tuyapi/cloud { a: 'tuya.m.user.email.register', @tuyapi/cloud deviceId: 'e3rv1lg9tuptv3lorlhq53dxptghd8os9m50lu2xcxpe', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 't9d59wv99mnpa89uh3e3', @tuyapi/cloud time: 1535976311, @tuyapi/cloud postData: '{"countryCode":"EU","email":"[email protected]","passwd":"db492f0ed648738a8fe0fe36246b18bb"}', @tuyapi/cloud sign: '60e643e3c21e53d213d346ba7a32b075' } +9ms @tuyapi/cloud Received response: +921ms @tuyapi/cloud {"result":{"dataVersion":0,"sex":0,"tempUnit":1,"headPic":"","sid":"az153597j6311240LyPhmv83e80f8eac7ab9dc89419509be2a6857ef","ecode":"z3z55567395zz13a","uid":"az1535976311240LPhmv","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":"p1108942","email":"hidden","snsNickname":"","improveCompanyInfo":false,"username":"hidden"},"t":1535976311403,"success":true,"status":"ok"} @tuyapi/cloud +1ms @tuyapi/cloud Sending parameters: +5ms @tuyapi/cloud { a: 'tuya.m.device.token.create', @tuyapi/cloud deviceId: 'e3rv1lg9tuptv3lorlhq53dxptghd8os9m50lu2xcxpe', @tuyapi/cloud os: 'Linux', @tuyapi/cloud lang: 'en', @tuyapi/cloud v: '1.0', @tuyapi/cloud clientId: 't9d59wv99mnpa89uh3e3', @tuyapi/cloud time: 1535976312, @tuyapi/cloud postData: '{"timeZone":"+01:00"}', @tuyapi/cloud sid: 'az153597j6311240LyPhmv83e80f8eac7ab9dc89419509be2a6857ef', @tuyapi/cloud sign: '9c0a16093af9692f7bc8f3d11f65ba4a' } +1ms @tuyapi/cloud Received response: +192ms @tuyapi/cloud {"t":1535976311740,"success":false,"errorCode":"USER_SESSION_INVALID","status":"error","errorMsg":"Session Expired, please log in again"} @tuyapi/cloud +1ms (node:885) UnhandledPromiseRejectionWarning: #<Object> (node:885) 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 not handled with .catch(). (rejection id: 1) (node:885) [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.

However I still get the same error after trying to connect the powerstrip.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@dickieblack as long as the adapter's enabled it should work. Would you mind capturing packets (from a different computer) during the linking process and sending me the resulting file? I just want to make sure the Pi is correctly broadcasting the setup packets.

@denzel1994 it looks like that app is just a rebranding of Tuya Smart, so your device should be compatible.

I think it's fairly conclusive at this point that it's not a regional issue, because when people in the EU change their region to EU API calls result in USER_SESSION_INVALID. For the same reason, the timezone parameter is not likely to be at fault either. Therefore, it's probably some issue with devices broadcasting the packets.

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

Hi, I think you could be right about the broadcasting. I ran WireShark on a PC whilst running the dev.js link wizard and didn’t see any obvious broadcasts. My Raspberry Pi is running OSMC. I did have the wireless adapter disabled, but turning it on a rebooting made no difference.

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

Actually, I had my packet filter wrong. Now I can see broadcasts from my Pi - UDP source port 63145, dst 30011. If I look at the packets though, the data part is just zeroes. A similar broadcast packet from a Nas device has hex data.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Sounds like it's working.

There is no data in the UDP packets; Tuya instead uses a clever method of encoding the data into packet lengths.

If you enable Wireshark's Len column you should see a repeating pattern being transmitted.

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

Ok, I can see the length varies through the broadcasts. And I am sniffing traffic on a wireless adapter on the PC, so the Pi is definitely transmitting the packets in a way that is being broadcast by my router on the wireless network (I had wondered if it was preventing broadcasts from the wired into wireless, but that does not seem to be the case).

from tuyapi.

chsims1 avatar chsims1 commented on May 24, 2024

My device has finally linked ok using the original link-wizard. The problem was network related. My home network consists of a router plus various APs with different ssids, and I suspect the device wasn't being "seen" from one side of the network to another. Once I ensured that both the Tuya device and the device running the linker were on the exact same network ssid, then it proceeded quite happily.

from tuyapi.

codehearts avatar codehearts commented on May 24, 2024

My network consists of a single router with 2.4G and 5G bands, but the laptop I was linking from was on the 2.4G band. It took maybe a hundred tries or so before the link would succeed.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@chsims1 what do you mean? Would you mind running a few tests and confirming that your computer must be connected to the target SSID for a successful link?

@codehearts during unsuccessful links, did you hear your device click?

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

@chsims1 I think this might be similar to my issue - I also have multiple APs for the same network. Whilst I can see the broadcast packets on a PC, potentially this is connecting to a different AP than the Tuya devices, or they aren’t all sending the broadcasts.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

A relevant note that I should probably put up somewhere: Tuya devices can only connect to a 2.4GHz network. If you have a duel-band network where both networks have the same SSID; that's fine. But if you're trying to link a Tuya device to a 5Ghz network it's not gonna work.

from tuyapi.

denzel1994 avatar denzel1994 commented on May 24, 2024

@codetheweb However I can‘t connect my device to the Tuya Smart App.

from tuyapi.

codehearts avatar codehearts commented on May 24, 2024

@codetheweb No clicks when it failed to register. I can't remember if there was a click when it succeeded, either; at some point I was running tuya-cli link in a while loop and letting it go

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@denzel1994 well, that's your issue. If you can't link it with the official app it's not gonna work with tuya-cli. Is the target network on 2.4Ghz?

from tuyapi.

denzel1994 avatar denzel1994 commented on May 24, 2024

Well the powerstrip opens up it’s own Wifi that you have to connect to, then open the Meross App and then pick the local WiFi and enter the password.

The Tuya App works completely different from what I can see. It immediately asks for the password of the WiFi my phone is connected to.

Yeah my local WiFi ist 2,4 and 5 GHz in the same SSID

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@denzel1994 usually there's two options for linking. The AP mode, like you explain above, and the UDP method like my package uses. Are you sure there's not a different option for linking? If not, my linking package won't work for your device.

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

broadcast capture.zip
Hi, I have learned a bit more about Wireshark and packet captures and have created one that is just broadcast packets (so its small enough to upload). I can see the repeating pattern UDP packets from 192.168.1.155 - my Raspberry Pi - captured from a PC about 50 cm from the Tuya device. The link never connects. If I then open the Tuya app om my iPhone, i see the same UDP packets, but this time the device registers to the app immediately. I think this means that the infomration is deinfitely being broadcast by the rPi, so if you wan to look at the data, hopefully this will help. Thanks, Richard

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Just glanced through your capture and everything looks good @dickieblack. You can see that there's a beginning pattern of Len = [1, 3, 6, 10] when using my package. Can you confirm that the app uses the same pattern?

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

hi, I included the capture from the app too - the .27 address is my iPhone

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

sorry, hit send too early - ...and I can see the same patter there. I am guessing this means everything should be working?

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@dickieblack it looks like the pattern being transmitted by the Tuya app is slightly different - lots of short segments in the beginning. I'll have to look into this more.

from tuyapi.

koldogut avatar koldogut commented on May 24, 2024

Dear all,

After reading every single word of this thread and just a second before shooting myself I realized that my SSID first word is Uppercase, so i tried writing it so and it worked!

from tuyapi.

koldogut avatar koldogut commented on May 24, 2024

Now my problem is that Homekit service does not start after adding the accessory, but this is for other thread ...

from tuyapi.

dickieblack avatar dickieblack commented on May 24, 2024

@codetheweb I have re-captured the packets after reading the last messages above, just in case I'd got the case sensitivity wrong - and also used the original link wizard in case the changes to region were actually causing the issues. I see the same set of repeating short packets for boith the Raspberry Pi (.155 IP) and mthe app on my phone (.27 address).

broadcast capture2.zip

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Hey everyone, I created a short survey to hopefully collect some more data on why the linking process works for some people and doesn't for others.

I'd really appreciate it if people took it, including those who it worked for and those who it didn't. Link: https://codetheweb.typeform.com/to/rTXsWg.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

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

Edit: I've received 8 responses to the survey so far. It's worked for people in the Americas and Europe with a multitude of different time zones, so those parameters are not the problem. Overall, there seems to be no correlating factors between machine & code configuration and whether or not it works. I think at this point it's a device issue.

from tuyapi.

TemnosHD avatar TemnosHD commented on May 24, 2024

I've solved the exact problem by switching to a different Pi. In my case I suspect that the issue was that I had my Pi connected over ethernet but when I used a Pi over Wifi it worked flawlessly. It didn't work either when I tried it on a VM with a bridged adapter. So I guess you should always double check if you have "full" control over the Wifi adapter 😅

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Combining issue #80 with this one. Pinging @wmbrown2, @Enika, @StoatsCoding, @alfb113, and @erichter2018 so they'll be added to this issue.

from tuyapi.

erichter2018 avatar erichter2018 commented on May 24, 2024

Just as an update, I bought another plug from a different manufacturer. Same result.

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@denzel1994 i also now have such a Meross thing and hoped it is compatible. But in fact: no udp packets on port 6666 and no open tcp Port 6668 on the device. So, seems something different. I will look into wireshark tonight and then we will see. But different issue then

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

I also tried long time today till it worked for me to connect 2 devices.
I was trying my MacBook also in the same Wifi (yes 2,4GHz, disabled all 5GHz before) and no success.

Finally I needed to use a wired Linux and then I was able to register the two devices in in sum 4 tries ... so all in all not that optimal.

Using the app I was able to add both before without any problem, also while my mobile phone was in 5GHz Wifi network!

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

Some more Infos what I noticed:

  • As I used the smartlife app first and used Charles to sniff a bit I saw that "countryCode" was set to "49" (means Germany) For this account and the EU URLs were used ... so maybe they changed things?
  • Now with an own "developer account" as needed for this lib Ialso registered on EU page and with Germany as country, but also for me the user data retured after login are AZ and containing the US URLs so something is strange there, but maybe they want it to.
    If I set to EU then I also get a "session invalid", but as said above ... mybe it is no EU account at all technically

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

When I monitor it and especially when sending from wifi devices itreally could be a timing issue when you say that the "protocol" is a set of udp messages in correct order and timing and such ... maybe this do no work always ... One post above said that it was "faster" when sended by the app ... maybe an idea?

from tuyapi.

jrcharles avatar jrcharles commented on May 24, 2024

Hello,

I've read everything on here, and it's not working for me.

Updated both tuyapi/cloud and /link
Outlets are able to connect via an iPhone
-devices are updated to latest firmware

Terminal shows:
✖ 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

I receive this if I use:
tuya-cli link
and tuya-cli link-wizard

Raspberry pi is connected to hardwire and 2.4GHz Wifi.

It seems the issue is either the device cannot connect to tuya cloud?

Any help is much appreciated.

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

Hey @BillSobel, have you seen anything like this when you use your C# linking code? I'm trying to debug this and running out of ideas.

Also, how do you sniff UDP packets when the app links with the device in AP mode?

from tuyapi.

BillSobel avatar BillSobel commented on May 24, 2024

@codetheweb HI Max. I've found the linking in SmartLink mode is highly dependent on the power of the AP broadcasting. Had a few devices that could not link until I moved them physically closer to the AP that was actually broadcasting (my laptop was 5ghz to the network, so network was rebroadcasting on 2.4ghz). I'd try the device much closer too the AP. As for sniffing AP traffic, since its broadcast without TLS, Wireshark should be able to see it...

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@BillSobel my device is physically 5-6 feet away from my computer, and given the number of people seeing this issue I think it's probably something else (although maybe it's part of the problem).

I think I figured out the packet sniffing issue: the packets that I'm trying to sniff are non-existent. Apparently my school network does not broadcast all packets sent to 255.255.255.255 over their AP nodes.

To compare packet captures between the app and my code, I set up a WiFi hotspot and sniffed the HTTP(s) traffic during app setup to end up with these parameters:

  • SSID: helloworld
  • Password: testTuya
  • Token: dpZqiTck
  • Secret: C1dq

I'd really appreciate it if you could run through these captures and see what you think, and/or do a packet capture of your code with these parameters. I just really don't know what's going on.

captures.zip

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

Yesterday I got a new device (3 plug thing) and i needed many tries to register them. The "wired way" it worked directly last time was not working this time, but my mac in same 2,4GHz wlan as the devie worked at the 3-4th try (one try was to have the register run since device disabled the "flashing light" :-)
So it works ... but needs some tries sometimes ...

When I looked at the debug output I had the feeling that it really could be a timing issue ... maybe try the calls a bit faster (programming wise) to work around network latencies ?!

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

TL;DR: current linking method probably won't work in the future, I'm looking into using a proxy instead.

My code is generating a slightly different set of packets than the app, which is probably why it works for some devices and not for others (@Apollon77, I tried removing the delays and it still didn't work). The fact that it might take multiple retries for certain devices is probably a result of one of the parameter's length not being encoded properly.

However, all the above is probably moot as @eddeandres pointed out that apparently Tuya no longer allows "free" app creations, and now charges a $149 fee to acquire a pair of keys. Unfortunately, that probably means the end of support for the current linking scheme, as I doubt the majority of new users will be willing to fork over $149. I'm looking into using a proxy instead that sniffs for requests to Tuya servers and captures the token pair. If it works, it might actually end up being a better user experience.

Those of you who haven't gotten it working: for now, I would recommend just using Charles to sniff for the token pair. There's a guide here.

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

This is bad ... Could it be an option to recompile the Smart Life app to get their api secret then everything could work again but with the "official smart life" accountrs from the users ...

from tuyapi.

BillSobel avatar BillSobel commented on May 24, 2024

from tuyapi.

jrcharles avatar jrcharles commented on May 24, 2024

If anyone is still working on this...

I tried for days to make this work on my rp3 on ethernet.

I disconnected the ethernet and connected it to the built in wifi. Afterwards, I was able to reconnect the ethernet and it worked.

tuya-cli link-wizard set it up the first Time on both devices on wifi

from tuyapi.

BillSobel avatar BillSobel commented on May 24, 2024

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

I think "sharing the key" is a topic of trust because the owner of the account could access all devices and control them ... I do not know if someone is willing to share :-(

Key in App: shit :-(

Could it be an idea to contact them (the Tuya Cloud Guys) as "group of open source home automation developers" and ask them for maybe an "official" way supported from their side?

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@codetheweb For an proxy you would need to also terminate the SSL and re-encrypt before sending to the real server ... so as "charles" is doing by injecting an own root cert in the phone ... puuhhh

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

http://anyproxy.io/en/#proxy-https ...

from tuyapi.

BillSobel avatar BillSobel commented on May 24, 2024

from tuyapi.

eddeandres avatar eddeandres commented on May 24, 2024

from tuyapi.

BillSobel avatar BillSobel commented on May 24, 2024

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

I guess the other option is adding Tuya to Home Assistant and doing it that way.

What you mean with this? Or would the idea be to have "one" account for all the Home Assistant users ... I already thourght the same for ioBroker ...

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

From what I remember they pin the cert, so this wouldn’t work. I’ll have to go back and verify

But when capturing TLS traffic via Charles works then it should not be pinned because else also Charles would not work ... and I was also able to capture traffic using Charles with Smart Live App on iOS

from tuyapi.

NorthernMan54 avatar NorthernMan54 commented on May 24, 2024

from tuyapi.

NorthernMan54 avatar NorthernMan54 commented on May 24, 2024

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@Apollon77:
I have seen the anyproxy package, it's actually what I would probably base my implementation off of. I am not open to attempting to extract the key pair from Tuya's app for numerous reasons, including the simple fact that if a few hundred unauthorized people begin using it it's fairly easy for them to change.

The contents of the email that Tuya sent out (translated from Chinese):

respected user
Thank you for joining the big family of graffiti, now the graffiti launches the Amazon WWA quick certification free collar event, click to learn more!
Learn more
If you are unable to open the link above, you can try copying and pasting the link into your browser address:

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@NorthernMan54 When I signed up for the API key I called it homebridge, if wanted we could just reuse it.

My question is, if they change this now, how future proof it will be to use it. I think the Proxy idea will be more future proof because they can kill the free API accounts any time (especially when they see "traffic" on one of them)

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@codetheweb I have seen the anyproxy package, it's actually what I would probably base my implementation off of. I am not open to attempting to extract the key pair from Tuya's app for numerous reasons, including the simple fact that if a few hundred unauthorized people begin using it it's fairly easy for them to change.

agreed. I will also play around a bit with it ... I send you when I have something ... move this discussion to a new isseu?

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@codetheweb I played around a bit with AnyProxy and was working basically good. It generates the certificate key for your computer so nothing shared. I configured it to intercept all https traffic when host contains "tuya" and catched the response when the response contained tuya.m.my.group.device.list . then you get that full blob of data:

{"result":[{"result":[{"uid":"eu1539013901029biqMB","password":"f19281c5141e8e5d","protocolVer":"2.1","code":"tymesh1539014046","pv":"2.1","name":"tymesh1539014046","share":false,"id":"mebf2c43e9fd12e74256mt","ownerId":"2019615","meshId":"mebf2c43e9fd12e74256mt","localKey":"ed0dd970be35cfbc"}],"a":"tuya.m.my.group.mesh.list","t":1539872261369,"success":true,"v":"1.0","status":"ok"},{"result":{"geoName":"xxxxxxxxxxx","rooms":[{"name":"Wohnzimmer","displayOrder":0,"id":910154},{"name":"Hauptschlafzimmer","displayOrder":1,"id":910155},{"name":"Zweit-Schlafzimmer","displayOrder":2,"id":910156},{"name":"Esszimmer","displayOrder":3,"id":910157},{"name":"Küche","displayOrder":4,"id":910158},{"name":"Arbeitszimmer","displayOrder":5,"id":910159}],"gid":2019615,"background":"","groupId":2019615,"displayOrder":0,"name":"Fischer","admin":true,"lon":0,"id":645961,"lat":0},"a":"tuya.m.location.get","t":1539872261369,"success":true,"v":"2.0","status":"ok"},{"result":[],"a":"tuya.m.my.group.device.group.list","t":1539872261368,"success":true,"v":"1.0","status":"ok"},{"result":[{"devId":"34305060807d3a1d7178","dpMaxTime":1539872229429,"virtual":false,"productId":"8FAPq5h6gdV51Vcr","dps":{"1":false,"2":0,"3":1,"4":146,"5":31,"6":2283},"activeTime":1539811217,"ip":"91.89.163.25","lon":"8.345742","moduleMap":{"wifi":{"upgradeStatus":0,"bv":"5.27","cdv":"1.0.0","pv":"2.1","verSw":"1.0.1","isOnline":true,"id":2957892,"cadv":""},"mcu":{"upgradeStatus":0,"cdv":"","verSw":"1.0.1","isOnline":true,"id":2957893,"cadv":""}},"uuid":"34305060807d3a1d7178","name":"Steckdose 2","timezoneId":"Europe/Berlin","iconUrl":"https://images.tuyaus.com/smart/icon/1521522457nf46uh6z3tk3jag1m6bfq1tt9_0.jpg","lat":"49.035767","runtimeEnv":"prod","localKey":"183a1aexxxxxxxxxx"}],"a":"tuya.m.my.group.device.list","t":1539872261380,"success":true,"v":"1.0","status":"ok"},{"result":[{"schemaInfo":{"schema":"[{\"mode\":\"rw\",\"code\":\"switch_on\",\"name\":\"开关\",\"property\":{\"type\":\"bool\"},\"iconname\":\"icon-dp_power3\",\"id\":1,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"rw\",\"code\":\"countdown\",\"name\":\"延迟\",\"property\":{\"unit\":\"秒\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":2,\"type\":\"obj\",\"passive\":true,\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"add_ele\",\"name\":\"电量\",\"property\":{\"unit\":\"度\",\"min\":0,\"max\":500000,\"scale\":3,\"step\":100,\"type\":\"value\"},\"id\":3,\"type\":\"obj\",\"desc\":\"上报的为放大100倍之后的值,即上报56,实际值为0.56度\"},{\"mode\":\"ro\",\"code\":\"cur_current\",\"name\":\"电流\",\"property\":{\"unit\":\"mA\",\"min\":0,\"max\":30000,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":4,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"cur_power\",\"name\":\"功率\",\"property\":{\"unit\":\"W\",\"min\":0,\"max\":50000,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":5,\"type\":\"obj\",\"desc\":\"\"},{\"mode\":\"ro\",\"code\":\"cur_voltage\",\"name\":\"电压\",\"property\":{\"unit\":\"V\",\"min\":0,\"max\":2500,\"scale\":0,\"step\":1,\"type\":\"value\"},\"id\":6,\"type\":\"obj\",\"desc\":\"\"}]","schemaExt":"[]"},"capability":1,"uiInfo":{"phase":"release","appRnVersion":"5.1","rnFind":true,"ui":"000000012x_0.2.5","id":661346,"type":"RN"},"panelConfig":{},"shortcut":{"quickOpDps":[],"faultDps":[],"displayDps":[1],"switchDp":1,"displayMsgs":{"quickop_dp_switch_on":"Schakelaar ","dp_switch_on_on":"ON","quickop_dp_switch_on_on":"ON","dp_switch_on_off":"OFF","dp_switch_on":"Schakelaar ","quickop_dp_switch_on_off":"OFF"}},"i18nTime":1533717958591,"id":"8FAPq5h6gdV51Vcr","attribute":918400,"category":"cz","supportGroup":true,"meshCategory":""}],"a":"tuya.m.device.ref.info.my.list","t":1539872261381,"success":true,"v":"1.0","status":"ok"},{"result":{"2":[{"children":{"4":[{"displayOrder":0,"id":"910154"},{"displayOrder":1,"id":"910155"},{"displayOrder":2,"id":"910156"},{"displayOrder":3,"id":"910157"},{"displayOrder":4,"id":"910158"},{"displayOrder":5,"id":"910159"}]},"id":"645961"}],"4":[{"children":{"6":[{"displayOrder":1,"id":"34305060807d3a1d7178"}]},"id":"910154"}]},"a":"tuya.m.my.group.device.relation.list","t":1539872261368,"success":true,"v":"1.0","status":"ok"},{"result":[],"a":"tuya.m.my.shared.device.group.list","t":1539872261368,"success":true,"v":"1.0","status":"ok"},{"result":[],"a":"tuya.m.my.shared.device.list","t":1539872261370,"success":true,"v":"1.0","status":"ok"}],"t":1539872261381,"success":true,"status":"ok"}

For me this would contain anything I would need. The devices, the localkeys and also the "data schema".

here the files. Install anyproxy via npm beforehand then simply execute node proxy.js ... web interface is also there for getting the certs file
proxy.zip

from tuyapi.

eddeandres avatar eddeandres commented on May 24, 2024

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

For my proxy code: would be great if someone with Android could test it tinder if the json is the same ...

from tuyapi.

codetheweb avatar codetheweb commented on May 24, 2024

@Apollon77 nice, thanks. I'll check it out. (The response for Android and iOS should be the same.) Created new issue #91 for discussion.

@eddeandres although most people are probably using Tuya devices with HA and Homebridge, I would prefer to retain the flexibility of using other options.

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@eddeandres I still do not really get it ... I thought that also the python version uses the "get a free api account" idea, or not ?! If so the problems are the same in the end, or ?!

from tuyapi.

eddeandres avatar eddeandres commented on May 24, 2024

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@eddeandres interesting ... can you point ot the HA code for that so that I can have a look?!

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

Was stupid post ... because wrong

from tuyapi.

Apollon77 avatar Apollon77 commented on May 24, 2024

@eddeandres HA uses a Auth endpoint where they get a accesstoken and then use this to get device data on polling as a skill would do ... seems no way to get the localkey that way ...

from tuyapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.