TuyaAPI / cli

🔧 A CLI for Tuya devices
MIT License
270 stars 44 forks source link

Device-fetching problem #135

Closed pascaltippelt closed 3 years ago

pascaltippelt commented 3 years ago

Hi!

I use the "Smart Life" App and try to add a thermostat. I run into problems in step 4 ( https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md ). So I tried to get you debug-information:


root@testserver1:~# DEBUG=* tuya-cli wizard
? The API key from tuya.com: g5fhdkgpazlysjbpXXX
? The API secret from tuya.com 442b0ef9203d4abbb155a300d792xxxx
? Provide a 'virtual ID' of a device currently registered in the app: bf85eb218c23bb6ed3XXXX
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/token?grant_type=1',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687186160',
    sign: '68870857249089ABE48F4D13BFE2C251689CB8E518E412F19D3FEFFB07A86F21',
    client_id: 'g5fhdkgpazlysjbpXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'User-Agent': 'axios/0.21.4'
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyaeu.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +0ms
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/token?grant_type=1',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687186161',
    sign: '2B7E0353B1B76B9C6C30997DFD8ACC509B76FE4B6E00C3FFF992338DE2B4F578',
    client_id: 'g5fhdkgpazlysjbpXXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'User-Agent': 'axios/0.21.4'
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyaus.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +21ms
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/token?grant_type=1',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687186161',
    sign: '2B7E0353B1B76B9C6C30997DFD8ACC509B76FE4B6E00C3FFF992338DE2B4F578',
    client_id: 'g5fhdkgpazlysjbpXXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'User-Agent': 'axios/0.21.4'
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyacn.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +7ms
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/token?grant_type=1',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687186161',
    sign: '2B7E0353B1B76B9C6C30997DFD8ACC509B76FE4B6E00C3FFF992338DE2B4F578',
    client_id: 'g5fhdkgpazlysjbpXXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'User-Agent': 'axios/0.21.4'
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyain.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +6ms
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/devices/bf85eb218c23bb6ed3XXXX',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687186348',
    sign: 'E1BEBD520612958897D31AA93DB06AD163FAD3E713CB502779C93FA91840FF62',
    client_id: 'g5fhdkgpazlysjbpXXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '6ae1fd7d37597a8c1210932cddeb94fb',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'Content-Type': 'application/json',
    'User-Agent': 'axios/0.21.4',
    'Content-Length': 2
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyaeu.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +150ms
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/devices/bf85eb218c23bb6ed3XXXX',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687186795',
    sign: 'CCBF0EC984F6B643B4731DCF9FBD6C0EDD36C55C2B6258BC6B1EA8E32C9E5F7A',
    client_id: 'g5fhdkgpazlysjbpXXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '196cd48d65da53840cd7c344ba0366d5',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'Content-Type': 'application/json',
    'User-Agent': 'axios/0.21.4',
    'Content-Length': 2
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyain.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +447ms
  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/devices/bf85eb218c23bb6ed3XXXX',
  method: 'GET',
  headers: {
    Accept: 'application/json, text/plain, */*',
    t: '1633687187039',
    sign: 'DD5413619AFA14478861F4B00F18F157F2B5F34C150A0F3C77DDA3C2C190CB27',
    client_id: 'g5fhdkgpazlysjbpXXXX',
    sign_method: 'HMAC-SHA256',
    access_token: '04c63dd43ecd19e88d12ca98abe5e14e',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'Content-Type': 'application/json',
    'User-Agent': 'axios/0.21.4',
    'Content-Length': 2
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'openapi.tuyaus.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
} +244ms
[
  Error: 28841101: No permissions. This API is not subscribed.
      at /usr/local/lib/node_modules/@tuyapi/cli/lib/wizard.js:77:11
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at async Promise.all (index 0)
      at async list (/usr/local/lib/node_modules/@tuyapi/cli/lib/wizard.js:64:28),
  Error: 28841101: No permissions. This API is not subscribed.
      at /usr/local/lib/node_modules/@tuyapi/cli/lib/wizard.js:77:11
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at async Promise.all (index 1)
      at async list (/usr/local/lib/node_modules/@tuyapi/cli/lib/wizard.js:64:28),
  Error: GET_TOKEN_FAILED 2007, your ip(89.12.48.238) cross-region access is not allowed
      at TuyaOpenApiClient.<anonymous> (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuya/tuya-connector-nodejs/lib/core/client.js:123:35)
      at step (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuya/tuya-connector-nodejs/lib/core/client.js:52:23)
      at Object.next (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuya/tuya-connector-nodejs/lib/core/client.js:33:53)
      at fulfilled (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuya/tuya-connector-nodejs/lib/core/client.js:24:58)
      at processTicksAndRejections (internal/process/task_queues.js:97:5),
  Error: 28841101: No permissions. This API is not subscribed.
      at /usr/local/lib/node_modules/@tuyapi/cli/lib/wizard.js:77:11
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at async Promise.all (index 3)
      at async list (/usr/local/lib/node_modules/@tuyapi/cli/lib/wizard.js:64:28)
]
There was an issue fetching that device. Make sure your account is linked and the ID is correct.```

I am not completely shure, what "This API is not subscribed." means. Could you tell me, what to do?

Best regards

Pascal
codetheweb commented 3 years ago

Sounds like you might have missed step 3.

pascaltippelt commented 3 years ago

There was actually a fault on tuya's side, so closed.

Thank you for your help.