[Solved] Tuya curtain integration

HI
We have a tuya curtain switch (model sc400w-eu)
I followed the instructions found here: https://community.openhab.org/t/step-by-step-guide-for-adding-tuya-bulbs-wi-fi-smart-led-smart-life-app-to-oh2-using-tuya-mqtt-js-by-agentk

I think everything is correctly installed but I can’t get the blinds to move.
I defined the thing with a channel as a Rollershutter with the command
tuya/tuyaIDTuyaKeyf/IP/command

But i don’t know how to define the Open/Close/Stop Commands
and the tuya-mqtt debug output is

TuyAPI:device Connected to device. undefined (192.168.1.153, bf21e25641ab7da07cydnr, xxxxxxx) +91ms
TuyAPI:device GET Payload: +3ms
TuyAPI:device { gwId: ‘bf21e25641ab7da07cydnr’, devId: ‘bf21e25641ab7da07cydnr’ } +1ms
TuyAPI:mqtt command is JSON +158ms
TuyAPI:mqtt receive command 2 +0ms
TuyAPI:device set: 2 +47ms
(node:4259) UnhandledPromiseRejectionWarning: TypeError: No arguments were passed.
at CustomTuyAPI.set (/etc/openhab2/scripts/tuya-mqtt/node_modules/tuyapi/index.js:159:13)
at /etc/openhab2/scripts/tuya-mqtt/tuya-device.js:215:25
at new Promise ()
at TuyaDevice.set (/etc/openhab2/scripts/tuya-mqtt/tuya-device.js:214:16)
at /etc/openhab2/scripts/tuya-mqtt/tuya-mqtt.js:194:32
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:4259) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4259) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
TuyAPI Received response +78ms
TuyAPI 000055aa000000000000000a0000002c00000001a90f48bdd0339942fa3bc1f7488dadbdfdc0ad399612a65b72bf5253b2731ae38a9005dd0000aa55 +2ms
Cleanup Uncaught Exception… Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
at Decipheriv.final (internal/crypto/cipher.js:172:29)
at TuyaCipher.decrypt (/etc/openhab2/scripts/tuya-mqtt/node_modules/tuyapi/lib/cipher.js:65:24)
at Socket. (/etc/openhab2/scripts/tuya-mqtt/node_modules/tuyapi/index.js:345:39)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23) +0ms
TuyAPI:device Disconnect from TuyAPI Device +50ms
TuyAPI Disconnect +25ms

and the process dies

So… I don’t know what to do! Is a problem of the tuya-api, or the tuya-mqtt integration or is just a problem of configuration?
Can someone help me! :wink:
Thanks

Can you show us your full Thing configuration?

hi, @hafniumzinc
I created it with the paperUI, I show you the REST json export:

{
  "statusInfo": {
    "status": "ONLINE",
    "statusDetail": "NONE"
  },
  "editable": true,
  "label": "Persiana_Est",
  "bridgeUID": "mqtt:broker:MQTTBroker",
  "configuration": {},
  "properties": {},
  "UID": "mqtt:topic:Persiana_Est",
  "thingTypeUID": "mqtt:topic",
  "channels": [
    {
      "linkedItems": [
        "Persiana_Est_"
      ],
      "uid": "mqtt:topic:Persiana_Est:persiana",
      "id": "persiana",
      "channelTypeUID": "mqtt:rollershutter",
      "itemType": "Rollershutter",
      "kind": "STATE",
      "defaultTags": [],
      "properties": {},
      "configuration": {
        "commandTopic": "tuya/bf21e25641ab7da07cydnr/*********/192.168.1.153/command",
        "stop": "Stop",
        "stateTopic": "tuya/bf21e25641ab7da07cydnr/*********/192.168.1.153/state",
        "off": "Close",
        "on": "Open"
      }
    }
  ],
  "location": "Estudi"
}

HI I’m almost there
I have two different tuya courtain and I can operate them from the tuyapi sample code, but I can’t do it using the tuya-mqtt library
I had to solve an error when sending a json in the tuyta-mqtt code
but when it receives the answer from the tuya it fails.
I’ll do a fork of the project and try to solve it because I see that there are some pull request unattended for a long time…

At the end it works,
I took a fork of the tuya-mqtt and I did some extra changes. To adapt it to the last version of tuyapi
the project is here:

  • Now you don’t have to put the IP when defining the channel: only Tuya/deviceId/localKey/Command
  • for blinds you need to define the message for open/close/stop as
    "{ \"set\": \"close\"}" (I have two models , one is open/close/stop, while the other 1/2/3 (there was an error on that)
  • The full tuya-mqtt could be optimized (to reduce the traffic, to detect all devices at the same time) to disconnect after a while) , but it works!