- 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
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.
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.
- 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.
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
You can‘t scan for the MQTT-Channels, you have to define them manually - for example:
PS: On your screenshot it seems that you didn‘t specify the right MQTT-Server data: Please check your IP and Port-Settings
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!
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 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 ( http://mqtt-explorer.com ) 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’,
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
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.
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’,
name: ‘Living Room Coil plug’,
name: ‘WiFi Plug’,
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?