gtalusan / eufy-device-id-js

This Javascript program allows you to obtain the device ID & local key for your Eufy devices without having to rely on running an old version of their Android app.
0 stars 0 forks source link

Output <Home> is received, but not <Device> #1

Open Defplayr opened 2 months ago

Defplayr commented 2 months ago

Expected Behaviour: Query returns: Home: 'home ID' Device: RoboVac, device ID 'device ID', local key 'local key'

Actual Behaviour: Runs apparently without problem, but returns just a single line: Home: 'nine numbers here' No Device info is received

Device is correctly seen by the Android Euly app and controllable. Also seen by Google Assistant and controllable.

I've removed robovac from Euly account, re entered details, reset device and re-connected to WiFi, all to no avail...

Line 226 in clients.js has an entry for the version number of the 'list devices'API (currently 1.0). This will take 1.1 and still run, but 1.2 throws an 'API version error'.

gtalusan commented 2 months ago

Not sure I can help too much in this regard.

If you add some console.logs to _request then you can share what's coming back in the response:

        const response = await this.session.post(url.toString(), Object.keys(data).length > 0 ? qs.stringify({ postData: encodedPostData }) : undefined);

        console.log(url);                         // <-- ADD
        console.log(response.data);    // <-- ADD
        if (!response.data.result) {
            throw new Error(`No 'result' key in the response: ${JSON.stringify(response.data)}`);
        }

For me, the response looks like this:

{
  result: [
    {
      activeTime: 1721252925,
      category: 'sd',
      categoryCode: 'wf_sd',
      devAttribute: 67,
      devId: 'XXXXX',
      devKey: '',
      dpMaxTime: 1725938744815,
      dpName: {},
      dps: [Object],
      iconUrl: 'https://images.tuyaus.com/smart/icon/ay1529982304505OYAXg/d7841b3c508cb26cc0658da1efe48b4c.png',
      ip: 'XXXXXX',
      lat: '0',
      localKey: 'XXXXXXXX',
      lon: '0',
      mac: 'XXXXXXX',
      moduleMap: [Object],
      name: 'eufy RoboVac X8',
      productId: 'XXXXX',
      runtimeEnv: 'prod',
      skills: [Object],
      timezoneId: 'America/New_York',
      uuid: 'XXXXXX',
      virtual: false
    }
  ],
  t: 1725940241002,
  success: true,
  status: 'ok'
}
gtalusan commented 2 months ago

One more thing you could try is to change listDevices to use tuya.m.my.shared.device.list instead of tuya.m.my.group.device.list.

Defplayr commented 2 months ago

Thank you for the super quick response.

Changing listDevices made no difference

Console output for listDevices = tuya.m.my.group.device.list (not including first part where Home is correctly retreived)

URL { href: 'https://a1.tuyaeu.com/api.json?appVersion=2.4.0&deviceId=8534c8ec0ed0sz8TvEDnIZqr44eNM1ipHFw0NNRQbUEm&platform=sdk_gphone64_arm64&clientId=yx5v9uc3ef9wg3v9atje&lang=en&osSystem=12&os=Android&timeZoneId=Europe%2FLondon&ttid=android&et=0.0.1&sdkVersion=3.0.8cAnker&sid=eu172565b1865501EYXmExU3109abda9e10dea8e6ef5bbf656cf2ba4&time=1725963175&requestId=f1b923a4-ad44-45f4-8a12-d16f569016b5&a=tuya.m.my.group.device.list&v=1.0&gid=203864334&sign=0cf5f280cb3ad468b643987cb1eda3f3abeef55ee06b26bd8c59c93ef99ed44c', origin: 'https://a1.tuyaeu.com', protocol: 'https:', username: '', password: '', host: 'a1.tuyaeu.com', hostname: 'a1.tuyaeu.com', port: '', pathname: '/api.json', search: '?appVersion=2.4.0&deviceId=8534c8ec0ed0sz8TvEDnIZqr44eNM1ipHFw0NNRQbUEm&platform=sdk_gphone64_arm64&clientId=yx5v9uc3ef9wg3v9atje&lang=en&osSystem=12&os=Android&timeZoneId=Europe%2FLondon&ttid=android&et=0.0.1&sdkVersion=3.0.8cAnker&sid=eu172565b1865501EYXmExU3109abda9e10dea8e6ef5bbf656cf2ba4&time=1725963175&requestId=f1b923a4-ad44-45f4-8a12-d16f569016b5&a=tuya.m.my.group.device.list&v=1.0&gid=203864334&sign=0cf5f280cb3ad468b643987cb1eda3f3abeef55ee06b26bd8c59c93ef99ed44c', searchParams: URLSearchParams { 'appVersion' => '2.4.0', 'deviceId' => '8534c8ec0ed0sz8TvEDnIZqr44eNM1ipHFw0NNRQbUEm', 'platform' => 'sdk_gphone64_arm64', 'clientId' => 'yx5v9uc3ef9wg3v9atje', 'lang' => 'en', 'osSystem' => '12', 'os' => 'Android', 'timeZoneId' => 'Europe/London', 'ttid' => 'android', 'et' => '0.0.1', 'sdkVersion' => '3.0.8cAnker', 'sid' => 'eu172565b1865501EYXmExU3109abda9e10dea8e6ef5bbf656cf2ba4', 'time' => '1725963175', 'requestId' => 'f1b923a4-ad44-45f4-8a12-d16f569016b5', 'a' => 'tuya.m.my.group.device.list', 'v' => '1.0', 'gid' => '203864334', 'sign' => '0cf5f280cb3ad468b643987cb1eda3f3abeef55ee06b26bd8c59c93ef99ed44c' }, hash: '' } { result: [], t: 1725963176505, success: true, status: 'ok' }

Console output for listDevices = tuya.m.my.shared.device.list

URL { href: 'https://a1.tuyaeu.com/api.json?appVersion=2.4.0&deviceId=8534c8ec0ed0UxwuonrJJseyG1hLI20RUrrwPGDU2yqt&platform=sdk_gphone64_arm64&clientId=yx5v9uc3ef9wg3v9atje&lang=en&osSystem=12&os=Android&timeZoneId=Europe%2FLondon&ttid=android&et=0.0.1&sdkVersion=3.0.8cAnker&sid=eu172565M1865501EXXmExW3d4088fc8638cc05304c3e52506323456&time=1725962900&requestId=516b2796-e8cc-4f13-8bef-be72166dc7e4&a=tuya.m.my.shared.device.list&v=1.0&gid=203864334&sign=3b830f7ce7e603f45f39787d6df4808bc3fcf985bd278b88e88f21deae10ac0f', origin: 'https://a1.tuyaeu.com', protocol: 'https:', username: '', password: '', host: 'a1.tuyaeu.com', hostname: 'a1.tuyaeu.com', port: '', pathname: '/api.json', search: '?appVersion=2.4.0&deviceId=8534c8ec0ed0UxwuonrJJseyG1hLI20RUrrwPGDU2yqt&platform=sdk_gphone64_arm64&clientId=yx5v9uc3ef9wg3v9atje&lang=en&osSystem=12&os=Android&timeZoneId=Europe%2FLondon&ttid=android&et=0.0.1&sdkVersion=3.0.8cAnker&sid=eu172565M1865501EXXmExW3d4088fc8638cc05304c3e52506323456&time=1725962900&requestId=516b2796-e8cc-4f13-8bef-be72166dc7e4&a=tuya.m.my.shared.device.list&v=1.0&gid=203864334&sign=3b830f7ce7e603f45f39787d6df4808bc3fcf985bd278b88e88f21deae10ac0f', searchParams: URLSearchParams { 'appVersion' => '2.4.0', 'deviceId' => '8534c8ec0ed0UxwuonrJJseyG1hLI20RUrrwPGDU2yqt', 'platform' => 'sdk_gphone64_arm64', 'clientId' => 'yx5v9uc3ef9wg3v9atje', 'lang' => 'en', 'osSystem' => '12', 'os' => 'Android', 'timeZoneId' => 'Europe/London', 'ttid' => 'android', 'et' => '0.0.1', 'sdkVersion' => '3.0.8cAnker', 'sid' => 'eu172565M1865501EXXmExW3d4088fc8638cc05304c3e52506323456', 'time' => '1725962900', 'requestId' => '516b2796-e8cc-4f13-8bef-be72166dc7e4', 'a' => 'tuya.m.my.shared.device.list', 'v' => '1.0', 'gid' => '203864334', 'sign' => '3b830f7ce7e603f45f39787d6df4808bc3fcf985bd278b88e88f21deae10ac0f' }, hash: '' } { result: [], t: 1725962901461, success: true, status: 'ok' }

gtalusan commented 2 months ago

Ok, that's what I suspected. The response is returning success with an empty result. I don't think I can help much further. If there's new API being used by the Android app, then the code and parameters will need to be lifted out of it... or try MITM the tuyaeu.com server to dump the requests/responses from the app to the web server.

Defplayr commented 2 months ago

No problem, thank you for taking the time to look at it.

gtalusan commented 2 months ago

Try working your way through this: https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md

Defplayr commented 2 months ago

Ha! That's one of about 5 pages I've got open at the minute...