How do I connect tuya smart plugs to openhab?

  • Platform information:
    • Hardware: I’m using an old laptop that I formatted and installed ubuntu server on to. intel Core i5 -5200U/ 4gb ram/ 1tb hard drive
    • OS: Ubuntu Server 20.04.4
    • Java Runtime Environment: I have installed java I just have no clue which version
    • openHAB version: openhab 3
  • Issue of the topic: Connecting Tuya Power plugs to Openhab

Hi all,

So quickly on to the next question. I recently bought myself some tuya smart plugs without realizeing how difficult it would be to connect them to Openhab. :sweat:

I didn’t realize that I had to flash the plugs and thats not something I can do (I think) so instead I opted for a non flashing solution. I found the following: Tuya devices to Openhab via MQTT - a working solution (without flashing)!

Everything seem to be going fine till I came to step 5.

  1. Next you have to define your MQTT-channels - I simply did that via PaperUI. Use a “Generic MQTT Thing” (for example “MQTT Tuya”) and add your channels here according to your devices.conf:

I also had some permission issues (ESSA Error) with step 4 but got that sorted out and was able to install the node and run the package.

node tuya-mqtt.js

Nothing specific happened the cursor would just got to the next line and stay there.

I went to the Openhab MQTT bindings and tried to scan and install them. One came up and is online (but has no channels) the other says error in communication.

I’m not sure what to do or how to setup this up properly. Any help on would be great. And I can share any code or screen shots required just let me know.

You can find my second question here: How to setup Philip Hues Scenes

1 Like

You can‘t scan for the MQTT-Channels, you have to define them manually - for example:

1 Like

PS: On your screenshot it seems that you didn‘t specify the right MQTT-Server data: Please check your IP and Port-Settings

1 Like

How do I set the MQQT server data?

how do I get to this page?

Hang on, you don’t need the system broker - you can delete it… On the other mqtt-thing on top you have the tab “Channels” - here you can define your MQTT topics:

I tried several approaches to integrate my Tuya smarthome devices. I flashed a few to Tasmota and eventually got them working with MQTT, but most devices are not flashable over the air, so I tried setting up the Alexa SmartLife skill and using the amazonechocontrol. That worked pretty well, but then I found the smarthome/j Tuya binding, which has worked well for me and isn’t dependent on having the Internet connection or Amazon Alexa connected and working. You can learn more here: addons/bundles/org.smarthomej.binding.tuya at 3.2.x · smarthomej/addons · GitHub

To use it, you have to first make the smarthome/j bindings available, which you can find more about here: GitHub - smarthomej/addons: SmartHome/J addons for openHAB


It’s the same principle like tuya-mqtt - you only need a initial internet connection to get the device-id’s and the key. Then you can control them via LAN. But if this Binding is available for OH and tuya-mqtt is currently not maintained anymore, it might be the better solution!

1 Like

noted and deleted. Alright thanks and I’m guessing I have to add a channel and where do I get the relevant details to fill in?

I already have the device IDs and their keys. so that’s one hurdle down :slight_smile: I’ll try adding the channels… If i’m so close to the MQTT installation I’m going to try and finish that but if I keep hitting a road block I’ll google a tutorial on how to add bindings to OH via github and i’ll try the smarthome/J binding. Any specific tutorials on how to add bindings would be greatly appreciated.

The details you can take from the devices.conf. Or you use a tool like MQTT Explorer ( ) to make all topics visible

the devices.conf file was empty and actaully wasn’t there I had to created it and populate it with the details I got from the Tuya development platform (the device ID and key) I haven’t added any other details than that

name: ‘Wifi Plug-vdevo’,
id: ‘vdevo164743226744313’,
key: ‘783c00a8abfe45ec’

This is what the virtual device code looks like. Its the same details as all the other plug point details.

I’ll download and try the MQTT explorer and see what details that gives.


Downloaded and tried this is what I found… i’m not sure if I’ve even set the MQTT server up properly…

So tuya-mqtt isn‘t sending any data to the broker. Try to remove the colon at the end of your devices.conf and make sure node tuya-mqtt.js is running - then you should see it in MQTT explorer

1 Like

When using local tuya control, whether it’s tuya-mqtt or the smarthome/j binding, only one thing can be active. If you have your app open on your phone, close it. Don’t run both tuya-mqtt and the smarthome/j tuya binding at the same time.

1 Like

There are no colons at the end of code. I’ve copied and pasted all the code I’ve added to the device.conf file bellow. This is all there is in the file.

name: ‘Maids room Coil plug’,
id: ‘bf7ee48303cf5b2862oong’,
key: ‘d20300618aa6c911’
name: ‘Living Room Coil plug’,
id: ‘bfa91e44aa379aa33dhblm’,
key: ‘f6647f03016aa1fb’
name: ‘WiFi Plug’,
id: ‘bf77b1fd8612c6bd64pu16’,
key: ‘932d431138c073ec’

And this is how it appears after I’ve activated the node is that correct? should something more happen?:


you can try:

DEBUG=* node tuya-mqtt.js

Then you should see a bit more. Can you also post your config.json?

Sorry if this is a little away from smart plug but it is on topic with using the J Tuya binding.

Hi All,

I have managed to get Tuya device control of a smart Colour LED GU10 from OH3 using the GitHub - smarthomej/addons: SmartHome/J addons for openHAB however, I can’t seem to control/select Scenes from OH. If I select scenes with the Smart Life App I can see the string of “Scene Data” changing to match what is selected (For example 06464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000) but I can’t then apply that string to directly recall it on the device from OH. Is this a limitation/not possible or just me?

hi a question, how do you install something in openhab from github? i have problems with tuya-mqtt and would like to try this method. thank you