mrbungle64 / ecovacs-deebot.js

A Node.js library for running Ecovacs Deebot and yeedi vacuum cleaner robots
GNU General Public License v3.0
115 stars 37 forks source link

GB/WW api endpoint not found #406

Closed lockieluke closed 9 months ago

lockieluke commented 9 months ago

Is there an existing issue for this?

The problem

API Endpoint cannot be found

import 'dotenv/config';

import to from 'await-to-js';
import {EcoVacsAPI, countries as EcoVacsCountries} from 'ecovacs-deebot';
import nodeMachineId from 'node-machine-id';

const machineId = await nodeMachineId.machineId();
const deviceId = EcoVacsAPI.getDeviceId(machineId, 0);
const country = "gb";
const continent = EcoVacsCountries[country.toUpperCase()].continent.toLowerCase();

const api = new EcoVacsAPI(
    deviceId,
    country,
    continent,
    "ecovacs.com"
);

const email = process.env.EMAIL;
const password = process.env.PASSWORD;

try {
    await api.connect(email, EcoVacsAPI.md5(password));
} catch (err) {
    console.log(err);
    process.exit(1);
}

const [err, devices] = await to(api.devices());
if (err) {
    console.log(err);
    process.exit(1);
}

console.log(devices);

With which model does the problem occur?

Other model (Please fill out the fields at the bottom of the form)

From which source you have installed the library?

GitHub

Version of the ecovacs-deebot.js library

0.9.5

Version of Node.js

21.1.0

Operating system

MacOS

Anything in the logs that might be useful?

AxiosError: getaddrinfo ENOTFOUND gl-gb-api.ecovacs.com
    at Function.AxiosError.from (/Users/sherlockluk/Desktop/deebot-test/node_modules/axios/lib/core/AxiosError.js:89:14)
    at RedirectableRequest.handleRequestError (/Users/sherlockluk/Desktop/deebot-test/node_modules/axios/lib/adapters/http.js:577:25)
    at RedirectableRequest.emit (node:events:515:28)
    at RedirectableRequest.emit (node:domain:488:12)
    at ClientRequest.eventHandlers.<computed> (/Users/sherlockluk/Desktop/deebot-test/node_modules/follow-redirects/index.js:14:24)
    at ClientRequest.emit (node:events:515:28)
    at ClientRequest.emit (node:domain:488:12)
    at TLSSocket.socketErrorListener (node:_http_client:495:9)
    at TLSSocket.emit (node:events:515:28)
    at TLSSocket.emit (node:domain:488:12) {
  hostname: 'gl-gb-api.ecovacs.com',
  syscall: 'getaddrinfo',
  code: 'ENOTFOUND',
  errno: -3008,
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [ 'xhr', 'http' ],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function], Blob: [class Blob] },
    validateStatus: [Function: validateStatus],
    headers: AxiosHeaders {
      Accept: 'application/json, text/plain, */*',
      'User-Agent': 'axios/1.3.4',
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    params: URLSearchParams {
      'account' => 'wayluk@yahoo.com.hk',
      'password' => 'f8159fbc5f67b0ff128698ab9720d6a6',
      'authTimespan' => '1699395130700',
      'requestId' => 'd7d557f998f14b8e42c2a37efb0abb64',
      'authTimeZone' => 'GMT-8',
      'authAppkey' => '1520391301804',
      'authSign' => '66eb684cf3aae3f94cd92913a94dd86e' },
    method: 'get',
    url: '[redacted]',
    data: undefined
  },
  request: <ref *1> Writable {
    _writableState: WritableState {
      highWaterMark: 16384,
      length: 0,
      corked: 0,
      onwrite: [Function: bound onwrite],
      writelen: 0,
      bufferedIndex: 0,
      pendingcb: 0,
      [Symbol(kState)]: 34357356,
      [Symbol(kBufferedValue)]: null
    },
    _events: [Object: null prototype] {
      response: [Function: handleResponse],
      error: [Function: handleRequestError],
      socket: [Function: handleRequestSocket]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    _options: {
      maxRedirects: 21,
      maxBodyLength: Infinity,
      protocol: 'https:',
      path: '[redacted]',
      method: 'GET',
      headers: [Object: null prototype],
      agents: [Object],
      auth: undefined,
      beforeRedirect: [Function: dispatchBeforeRedirect],
      beforeRedirects: [Object],
      hostname: 'gl-gb-api.ecovacs.com',
      port: '',
      agent: undefined,
      nativeProtocols: [Object],
      pathname: '[redacted]',
      search: '[redacted]'
    },
    _ended: true,
    _ending: true,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 0,
    _requestBodyBuffers: [],
    _onNativeResponse: [Function (anonymous)],
    _currentRequest: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      _header: 'GET [redacted] HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'User-Agent: axios/1.3.4\r\n' +
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Host: gl-gb-api.ecovacs.com\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '[redacted]',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: [Function: emitRequestTimeout],
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'gl-gb-api.ecovacs.com',
      protocol: 'https:',
      _redirectable: [Circular *1],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kChunkedBuffer)]: [],
      [Symbol(kChunkedLength)]: 0,
      [Symbol(kSocket)]: [TLSSocket],
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: '[redacted]',
    [Symbol(kCapture)]: false
  },
  cause: Error: getaddrinfo ENOTFOUND gl-gb-api.ecovacs.com
      at __node_internal_captureLargerStackTrace (node:internal/errors:563:5)
      at __node_internal_ (node:internal/errors:782:10)
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'gl-gb-api.ecovacs.com'
  }
}


### Additional information

I have tried pinging the user using the `ping` command but it did not work
mrbungle64 commented 9 months ago

@lockieluke

"gb" is not a valid country code. You can find the available country codes here.