question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"tuya-cli link" results in Device(s) failed to be registered! / Error: permission deny

See original GitHub issue

Describe the bug Executing

tuya-cli link --api-key [..] --api-secret [..] --schema comfluxsmartapp --ssid 'fluxnet iot' --password [..] --region us

results in this:

✖ Device(s) failed to be registered!
Error: permission deny
    at TuyaLinkWizard.init (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/link/index.js:72:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async link (/usr/local/lib/node_modules/@tuyapi/cli/lib/link.js:45:3)

I modified api credentials intentionally and got other errors, so authentication by these should not be the problem. I executed the “tuya-cli link” command on 3 different systems (2x x86-64/Fedora36, 1x raspi4), all with this result. One of the systems was only to the WLAN connected which I use as parameters on the command line, that did not help either.

To Reproduce Steps to reproduce the behaviour, at least for me with the Tuya-user created as per instructions:

  1. execution of above command
  2. See error

Expected behaviour Device should be registered.

Debug Output api-key, api-secret ans wlan-password in the following were changed into […] .

[root@pi4 41°C ~]$ DEBUG=* tuya-cli link --api-key [..] --api-secret [..] --schema comfluxsmartapp --ssid 'fluxnet iot' --password [..] --region us
⠋ Registering devices(s)...  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: '1660049114938',
    sign: '04CF7E06CCA6EBC1EDA9390C026B69FD805F4CB6792D216E2AF775DF094E5486',
    client_id: '[..]',
    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],
      validateHeaderName: [Function: __node_internal_],
      validateHeaderValue: [Function: __node_internal_],
      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
⠹ Registering devices(s)...  follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'https:',
  path: '/v1.0/apps/comfluxsmartapp/user',
  method: 'POST',
  headers: {
    Accept: 'application/json, text/plain, */*',
    'Content-Type': 'application/json',
    t: '1660049116296',
    sign: '076F6865D304765916E4ED6B3003C1358547949E9E3B53A8AC257565FC502471',
    client_id: '[..]',
    sign_method: 'HMAC-SHA256',
    access_token: '622ca71a2406ae8faff8d134dd704252',
    Dev_lang: 'Nodejs',
    Dev_channel: 'SaaSFramework',
    'Signature-Headers': '',
    'User-Agent': 'axios/0.21.4',
    'Content-Length': 161
  },
  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],
      validateHeaderName: [Function: __node_internal_],
      validateHeaderValue: [Function: __node_internal_],
      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]
    }
  }
} +1s
✖ Device(s) failed to be registered!
Error: permission deny
    at TuyaLinkWizard.init (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/@tuyapi/link/index.js:72:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async link (/usr/local/lib/node_modules/@tuyapi/cli/lib/link.js:45:3)

Desktop (please complete the following information):

  • OS: Fedora
  • OS Version 36
  • Node Version v16.14.0 (I did also try latest node version, not packaged in Fedora but having npm update itself into /usr/local)

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

2reactions
s0x00ccommented, Nov 25, 2022

Hey, just to add to this issue for others that are finding this thread:

  • Make sure you are connecting to the correct datacenter! https://developer.tuya.com/en/docs/iot/Data_Center_Introduction?id=Kav2hlac2ppnw <= look up your country and it’s corresponding datacenter (mine wasn’t that obvious being in Europe)
  • Make sure to use the ‘TUYA Smart’ app itself (although they look exactly the same) don’t use a localized version, because the scanning of the QR-code will not work.

I hope this will be helpful for someone down the line.

1reaction
christianhorncommented, Nov 15, 2022

@waverly360 Wooho, thanks a bunch for putting this together! Thanks to your way to see “Get App Details”, I was able to verify that both of the projects I had created had the apps properly connected. The other settings also look good for me. Linking up the device then was for me the first part where I had to use the mobile, scan the QR-code and then find my smartplug - I had not seen any step like this in the official docs. From further testing here I conclude that actually my device is not Tuya compatible, it’s not getting picked up with the Android mobile via the “Smart Life App”, but only with the “+style app”. The device is a ゴウサンド/Gosund WP6-1, I had assumed it’s the Japanese variant of a supported plug, but that’s apparently not the case.

I can only encourage others who hit the issue reported to go through the steps from @waverly360 , and if succeeding to send a pull request to update the instructions. While these are not updated, consuming the official steps and the pieces from @waverly360 here seem like the way to go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Device(s) failed to be registered · Issue #462 - GitHub
Hello everyone, maybe this is linked to my account being new and you stating that this method is broken now, but according to...
Read more >
How to resolve it if the calling interface has an error code
solution: 1) First check if the device is paired with Tuya Smart APP, and then use the device Id in Tuya Smart APP...
Read more >
Sylvania Smart+ WiFi - #42 by quagmirert - Feature Requests
When it finally connected tuya-cli failed, it didn't output an id/key pair, but it was registered on my developer app. I was able...
Read more >
tuyapi - Bountysource
An easy-to-use API for devices that use Tuya's cloud services. ... known hosts. npm ERR! git clone git@github.com:tuyapi/cli Permission denied (publickey).
Read more >
Tuya: Login error (1106): permission deny : r/homeassistant
2021.11.0 I have been unable to interact with my Tuya devices. Logs are showing 1106 error which relates to incorrect username/password.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found