Step-by-Step guide for adding Tuya-bulbs, Wi-Fi smart LED (Smart Life app) to OH2 using tuya-mqtt.js by AgentK

Do you have a developer account or just an ordinary one?

Ok. I’ve reverted back to v 3.6.1 and I’ve found a 16 digit number in one of the packets I captured. hopefully this is the Local ID. Knowing my Device/Virtual ID and my Key/Local ID is there some way I can now use MQTT.fx to see the MQTT message from the alarm when it does something?

UPDATE: I now realise I’ve bitten off more than I can chew. To integrate a Tuya G30 Alarm with openHAB requires a lot more knowledge of programming than I have. Hopefully some day someone with that knowledge will work it out in the meantime I’ll just keep using Smart Life to access it remotely.

Guys, can you tell me if installation procedure adapted to latest openhab2? As I was following it and can not find services/mqtt.cfg file, can anybody point me out how to install these RGB switches in openhab2?


OK, now I have installed Tuya Binding from this resource (, now need to get the encryption key. How I can get it? Tried package capture, but it does not install certificate for some reason there for does not work properly, captures strange symbols, nothing else. Did anyone overcome that beast?

I’m having the exact same problem. Have you found a solution or work around?

Try tuya/ver3.3/ at the beginning

I’ve gone through all the steps. I ended up using the tsightler/tua-mqtt. The device I have is a 2-gang switch. The one switch works fine, but the other does not. I can turn it on and off from openhab, but i’m having an issue tracking the state from manual changes. Is my setup below correct for the second switch?

Thing mqtt:topic:tuya {
        Type switch : t_light_switch_foyer "Foyer" [ 
            on="{ \"dps\": 1, \"set\": true }",
            off="{ \"dps\": 1, \"set\": 0 }"
         Type switch : t_light_switch_front_porch "Front Porch" [ 
            on="{ \"dps\": 2, \"set\": true }",
            off="{ \"dps\": 2, \"set\": 0 }"
Switch foyer "Foyer" <light> (MainFloor) [ "Lighting" ] {channel="mqtt:topic:tuya:t_light_switch_foyer"}
Switch frontPorch "Front Porch" <light> (FrontPorch) [ "Lighting" ] {channel="mqtt:topic:tuya:t_light_switch_front_porch"}

Do you know what I should do to set integration with tuya in synchronous mode?
I use and it works fine but in asynchronous mode.

Hi everyone… Can’t seem to make it work and I need help debugging this thing.
I’m running OH 2.5 on Raspberry Pi 4 and I’m trying to control Tuya Led Strip.
I did the following steps:

  1. I already had an MQTT broker up and running, using it with other sensors. Successfully getting temp and humidity data from an ESP8266 based sensor.
  2. installed the .js script from AgentK
  3. I think I performed all the configurations including editing the config.json and tuyaapi-mqtt.service
  4. Noted the device ID
  5. Retrieved the local key using tuya-cli wizard method
  6. Created a new channel in my generic MQTT Thing with the following configurations:
    6.1 Channel type- ON/OFF (Switch)
    6.2 State topic- tuya/id/key/ip/state
    6.3 Command topic- tuya/id/key/ip/command
  7. Linked the channel to a switch item
  8. Controlled the switch from my sitemap
  9. And nothing happens…

Things I already checked:

  1. Broker details are correct at config.json
  2. Broker is working fine (getting data from the Temp sensor)
  3. Tried setting Custom On and Off values (1 and 0)
  4. Tried setting a string channel and sending it “ON” and “OFF” strings
  5. Tried sending values from a stand alone mqtt client to the command topic
  6. Rebooting the PI several times
  7. Tried changing the topics with different options at the top-

Sepecific questions I don’t understand:

  1. How can I check if the tuya-mqtt service is up and running correctly?
  2. What is the correct topic settings? There are several different versions in this long session…
  3. Does it matter that I’m trying to control a led strip and not a light bulb?
  4. Should I set something with the tuya-cli?

And other than that, any other thoughts on how to debug it and find the problem?

Thanks in advanced.

For checking tuya-mqtt service, try:

DEBUG=* node /etc/openhab2/scripts//tuya-mqtt/tuya-mqtt.js

1 Like

I have OH2 in a docker container - how can i use tuya-mqtt,js there ?

AAAAHHH! Thank you! I had been dorking around with certs and proxies and anything I could think of - and the 3.6.1 APK Mirror finally gave me the global keys file!

I got the tuya-mqtt installed and working (I used the fork which supports protocol v 3.3). I can control my lights no problem.

I had a question about the “dps” index numbers. I have a Merkury RGB bulb from Walmart (link HERE) and I was watching the transactions coming out of tuya-mqtt when controlling the bulb with the app.

Some of the DPS indices were obvious, like the ones for power (1), brightness (3), and setting the scene (2); but others are a mystery, and I see them getting set when I change scenes.

For example:

tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ true
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ "white"
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ 255
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ "ff00000000ffff"
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ "feedbb002c1a64"
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ "ffff3205ff000000ff00ffff00ff00ff0000ff"
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ "ffff3201ff0000"
tuya/eb31b3020ddf10759blnao/da8fdb33370bf37f/ "ffff3205ff000000ff00ffff00ff00ff0000ff"

Is there a way to find out what the other DPS indices mean? Or would someone know here?


Hellooooo, maybe someone available in 2020 to help me with my project? :frowning: I’m trying to manage my devices with mqtt in openhab, but I can’t, I have tried the steps you suggested, but nothing. Help

If this thread is still alive, can anyone provide some help as I can’t get this to work.
It seems that the dps is not sent to the device from Paper UI as I get this (I am using DEBUG on top of tuya-mqtt.js):

TuyAPI GET Payload: +3ms
TuyAPI {
TuyAPI gwId: ‘bfc8f65d319b4e4f87wcqv’,
TuyAPI devId: ‘bfc8f65d319b4e4f87wcqv’,
TuyAPI t: ‘1600938741’,
TuyAPI dps: {},
TuyAPI uid: ‘bfc8f65d319b4e4f87wcqv’
TuyAPI } +1ms
TuyAPI:mqtt Received command: { set: true } +82ms
TuyAPI:device set: { set: true } +12ms
TuyAPI SET Payload: +11ms
TuyAPI {
TuyAPI devId: ‘bfc8f65d319b4e4f87wcqv’,
TuyAPI gwId: ‘bfc8f65d319b4e4f87wcqv’,
TuyAPI uid: ‘’,
TuyAPI t: 1600938741,
TuyAPI dps: { ‘1’: true }
TuyAPI } +0ms
TuyAPI Received data: 000055aa000000010000000a0000002c0000000143f419dc669d9137904f7f66bd026f20c4e1dc5dff0aaf61cbdcf2ad87dc02ad1db3708b0000aa55 +16ms
TuyAPI Parsed: +3ms
TuyAPI {
TuyAPI payload: ‘parse data error’,
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +1ms

I’ve tried various inputs including
{ "dps": 1, "set": true }

I am connected to the device which is a basic Switch with 1 gang on or off… but I can’t achieve anything with OpenHAB (version 2.5.9)

I’ve been spending hours on this!

Looking at your devId/gwid I would think that you have a Tuya version 3.2 device. It is sadly not supported by the tyuapi and thus not by tuya-mqtt either.

I can’t remember from where I saw that my device is a Tuya version 3.3 device. But the problem may come from an unreadable schema. What would you think of this (delivered by njstuya) ?

{"id":"xxxxxxxxxxxxxxxxx","broadcast":{"ip":"","port":6668,"id":"xxxxxxxxxxxxxxxxx","gwID":"xxxxxxxxxxxxxxxxx","version":""},"schema":"C�\u0019�f��7�O⌂f�\u0002o ���]�\n�a����\u0002�"}

The version number is blank and the schema may be in chinese?

On Paper UI, “Custom On/Open Value” field put this: { “dps”: “1”, “set”: “1” }

On “Off” field, this: { “dps”: “1”, “set”: “2” }

It worked for me during a while, now I simply can’t have MQTT communication and I don’t know why! :frowning:

I just opened a new thread for integrating tuya devices using tuya-mqtt (which has been completely rewritten by @tsightler within the last weeks). As he also modified parts of the underlaying tuyapi, I was able to get devices to work which didn’t work with tuyapi before…

I am trying this process with a bunch of door sensors I bought from Aliexpress. They have a XR809 chip instead of the ESP8466. Any chance it will work?

I was able to retrieve ID and KEY for the devices, and the tuya-mqtt.js script is running, but the item remains as NULL. Below are some snippets:

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false, username="openhabian", password="XXXXXXXX" ]
            Thing mqtt:topic:tuya "Tuya" {
                Type switch : GF_T_Hallway_Door "Hallway Door" [ stateTopic="tuya/lightbulb//<ID>/<KEY>/192.168.1.XXX/state", commandTopic="tuya/lightbulb/<ID>/<KEY>/192.168.1.XXX/command"]
                Type switch : GF_T_Kitchen_Door "Kitchen Door" [ stateTopic="tuya/lightbulb/<ID>/<KEY>/192.168.1.XXX/state", commandTopic="tuya/lightbulb//<ID>/<KEY>/192.168.1.XXX/command"]

Switch GF_Hallway_Door "Hallway Door" (gSensor) {channel="mqtt:topic:tuya:GF_T_Hallway_Door" }

Did you try tuya/ver3.3/…?