Tuya integration configuration

Hello @pierre-gilles
In Gladys, after configuring the Cloud Tuya integration, when I select « Tuya discovery », I get the response « No device was discovered » even after the scan.

I have the same integration for HA (Home Assistant) which works — I first retrieved the Access Key, Secret Key, App account UID from the project created for HA. Then I created a new project for Gladys with a new configuration. The Tuya devices are correctly linked to the project but they do not appear in Gladys.
The Tuya service is reporting an error.
Excerpt from Gladys Docker logs
2024-10-26T12:19:33+0200 \u003cerror\u003e tuya.discoverDevices.js:38 (TuyaHandler.discoverDevices) Unable to load Tuya devices TypeError: Cannot destructure property ‹ list › of ‹ result › as it is undefined.
at TuyaHandler.loadDevices (/src/server/services/tuya/lib/tuya.loadDevices.js:25:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at TuyaHandler.discoverDevices (/src/server/services/tuya/lib/tuya.discoverDevices.js:35:15)
at discover (/src/server/services/tuya/api/tuya.controller.js:10:21)

Thank you in advance for your help

I’m referring you to @pierre-gilles’s message about this…
It seems that Tuya is unusable at the moment, until someone looks into it!

Thank you for the response,I will be patient

1 Like

Hi @Francis66, thanks for your feedback!

Indeed, since this summer all users have had the same feedback as you.

I already worked on it this summer but couldn’t find what was wrong; I was convinced until then that the Tuya API was no longer open for this use.

But I’m really curious to know how HA does it then.

Did you do anything particular on the HA side? When you created the API keys for HA, was it the same process as in Gladys or do they do something extra?

No, I don’t see any notable difference. Home Assistant (HA) has developed a new Tuya Smart Life integration to avoid having to revalidate permissions on Tuya IoT.
I just bought 3 Calex lamps for their aesthetics; I’ll look further into Tuya Convert to see if I can eliminate the cloud. Currently I’m mainly equipping myself with Zigbee2MQTT

1 Like

Actually, when I look at the Node.js package we use to connect to Tuya, everyone is complaining about the same issue — we’re not the only ones:

It’s infuriating, these cloud products, because we developed this service in July 2023 (Source: https://community.gladysassistant.com/t/gladys-assistant-4-26-gladys

Sorry for my request and for having wasted time because, in the end, the TUYA integration works very well in Gladys.

This malfunction was related to 2 problems.

  1. I no longer had rights to the API resources
  • access to Cloud Develop Base Resource and IoT Core because the Trial period had expired.
  1. For the zone: I had entered Western Europe instead of Central Europe

I found my lamps in « Tuya Discovery »

3 Likes

Ah, incredible! Because you’re not the only one who’s complained! I’ll send your post to the other users

@Francis66 I’ve added a message in the documentation that points to this topic:

Hello @Francis66

Thanks for pointing out the source of the problem. I confirm it’s the same for me.

However, I have a practical question: how did you reactivate the service? I did find the option to extend the trial period but it only offers a 6-month extension (which must be validated by Tuya…); so, will I have to do this every 6 months if that’s the only way?

Please confirm the response to the Tuya integration issue; this will save Pierre-Gilles time. Before starting with the Gladys starter kit, I was on HA (Home Assistant); the integration procedure is identical on the Tuya IoT side, with a « trial » period for authorizations. Following an email from Tuya notifying me of the expiration, I requested a 6-month extension, which was granted immediately. At the expiry of the second validation in December 2023 my commands and automations using Tuya hardware continued to be functional!! ?

However, during the integration into Gladys, Tuya had to verify my permissions. I was able to fill out a form requesting an exceptional extension of 1 to 6 months. The request was accepted within the next 10 minutes. I hope my integration will still be functional in 6 months…

However, I advise retrieving the « Local Key » associated with the « Id » of Tuya devices. Access rights are blocked when the authorization date is reached. This could be useful for local use.

1 Like

Excuse me for digging up an old thread but I have a problem with the Tuya integration:
I recently changed internet providers and since then the lamps I used with the Tuya integration no longer respond.

At first, I tried deleting the lamps present in the « devices » part of the integration to try to rediscover them and nothing was found… I saw this post: so I checked my access to « IoT Core » (I did not find « Cloud Develop Base Resouce ») and indeed the trial period had expired (I was also on the Europe Central cloud). I requested an extension which was accepted. Since then I tried discovery again and still nothing…

But in Gladys logs I have this when I validate the configuration:

 <warn> service.start.js:44 (Service.start) Unable to st                                                    art service tuya Error: connect ETIMEDOUT 2a05:d014:afa:af00:568a:5cc6:4603:c040                                                    :443
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '2xxxx:dxxx:axxxx:af00:568a:5cc6:4603:c040',
  port: 443,
  config: {
    url: 'https://openapi.tuyaeu.com/v1.3/iot-03/devices?last_row_key=\u0026source_id                                                    =euxxxxxxxxxxxx\u0026source_type=tuyaUser',
    method: 'get',
    data: '{}',
    headers: {
      Accept: 'application/json, text/plain, */*',
      t: '1737148959580',
      sign: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      client_id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
      sign_method: 'HMAC-SHA256',
      access_token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      Dev_lang: 'Nodejs',
      Dev_channel: 'SaaSFramework',
      'Signature-Headers': '',
      'Content-Type': 'application/json',
      'User-Agent': 'axios/0.21.4',
      'Content-Length': 2
    },
    params: {},
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    }
  },
  request: \u003cref *1\u003e Writable {
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      constructed: true,
      prefinished: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      [Symbol(kOnFinished)]: []
    },
    _events: [Object: null prototype] {
      response: [Function: handleResponse],
      error: [Function: handleRequestError]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    _options: {
      maxRedirects: 21,
      maxBodyLength: 10485760,
      protocol: 'https:',
      path: '/v1.3/iot-03/devices?last_row_key=\u0026source_id=euxxxxxxxxxxxxxxxxxxx\u0026s                                                    ource_type=tuyaUser',
      method: 'GET',
      headers: [Object],
      agent: undefined,
      agents: [Object],
      auth: undefined,
      hostname: 'openapi.tuyaeu.com',
      port: null,
      nativeProtocols: [Object],
      pathname: '/v1.3/iot-03/devices',
      search: '?last_row_key=\u0026source_id=euxxxxxxxxxxxxxxxxxxxxxxx\u0026source_type=tuyaUser'
    },
    _ended: false,
    _ending: true,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 2,
    _requestBodyBuffers: [ [Object] ],
    _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: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 2,
      _hasBody: true,
      _trailer: '',
      finished: false,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'GET /v1.3/iot-03/devices?last_row_key=\u0026source_id=euxxxxxxxxxxxxxxx                                                    AowJC\u0026source_type=tuyaUser HTTP/1.1\\r\\n' +
        'Accept: application/json, text/plain, */*\\r\\n' +
        't: 1737148959580\\r\\n' +
        'sign: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\                                                    r\\n' +
        'client_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\r\\n' +
        'sign_method: HMAC-SHA256\\r\\n' +
        'access_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\r\\n' +
        'Dev_lang: Nodejs\\r\\n' +
        'Dev_channel: SaaSFramework\\r\\n' +
        'Signature-Headers: \\r\\n' +
        'Content-Type: application/json\\r\\n' +
        'User-Agent: axios/0.21.4\\r\\n' +
        'Content-Length: 2\\r\\n' +
        'Host: openapi.tuyaeu.com\\r\\n' +
        'Connection: close\\r\\n' +
        '\\r\\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/v1.3/iot-03/devices?last_row_key=\u0026source_id=euxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\u0026s                                                    ource_type=tuyaUser',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'openapi.tuyaeu.com',
      protocol: 'https:',
      _redirectable: [Circular *1],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: 'https://openapi.tuyaeu.com/v1.3/iot-03/devices?last_row_key=\u0026s                                                    ource_id=euxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\u0026source_type=tuyaUser',
    [Symbol(kCapture)]: false
  },
  response: undefined,
  isAxiosError: true,
  toJSON: [Function: toJSON]
}

It looks like it’s timing out but I don’t know why…

It works fine with the Smart Home app on my phone and I can ping a lamp from Gladys without problem.

I wonder if the API URL changed or what!? ^^

Hi @Xenicle, are you sure you don’t have a network issue or a misconfiguration?

If I open the URL you provided, there is indeed a server at the other end:

(well, a token is missing to test, but the server is definitely there)

1 Like

I’ll check that! I thought of that too but haven’t « checked » yet…

However, from the mini-PC :

@gladys:~$ httping -c 3 -g https://openapi.tuyaeu.com/v1.3/iot-03/devices?last_row_key=\u0026source_id=\u0026source_type=tuyaUser
[2] 181345
[3] 181346
gladys@gladys:~$ Auto enabling SSL due to https-URL
PING openapi.tuyaeu.com:443 (/v1.3/iot-03/devices?last_row_key=):
connected to 3.69.78.245:443 (617 bytes), seq=0 time=132,80 ms
connected to 3.69.78.245:443 (617 bytes), seq=1 time= 72,15 ms
connected to 3.69.78.245:443 (617 bytes), seq=2 time= 70,65 ms
--- https://openapi.tuyaeu.com/v1.3/iot-03/devices?last_row_key= ping statistics ---
3 connects, 3 ok, 0,00% failed, time 3278ms
round
1 Like