I found several postings about adding tuya devices to OH. Thanks to @tsightler finally there is a working solution now.
Tom rewrote his whole code with some modifications on the underlaying TuyAPI. One of the highlights here is the easy naming (device names instead id’s) and the OH-friendly path (for example: if you have a power strip with multiple outlets, you can access the mqtt-topic easily by tuya/powerstrip/dps/2/state).
Please note that the underlaying TuyAPI doesn’t support protocol version 3.2 yet. On the other hand, I have a lot of tuya devices here and none are using the protocol version 3.2. Everytime I ran into a problem with a device not working, I just switched the pv from 3.1 to 3.3 or vice versa).
So here I want so share a short How-To:
Follow the instructions here and add all your devices within the (tuya-/smartlife)-app.
See section: Listing Tuya devices from the Tuya Smart or Smart Life apps (highly recommended)
In order to get tuya-mqtt running, you will need a running mqtt server. A step-by-step guide can be found here (section: Update for MQTT-Binding 2.4):
Installation of tuya-mqtt (I installed it in the OH-scripts-directory):
Now it’s time to configure the devices. You can use “tuya-cli wizard” to get a basic devices.conf. As this can be complex (especially if you run your devices in different VLANs) please read this first:
I had the problem that many of my devices are not flashable. But as you are now able to create a free account on iot.tuya.com, it’s pretty easy to get your neccessary device_id’s and keys. Still some effort but you will be able to get almost every tuya-device in without need to flash it first.
Especially the handling of the light bulbs is fantastic now with tuya-mqtt 3.0 - it even respects the white mode of some newer bulbs…
Is it just me, with some wrong configs, or is node.js really hungry for resources and therefore a basic RPi 3B+ isn’t enought for the job?
I mean, I’ve invested literally days on this subject and I could make it work! But in order to make it work I had to first run “node tuya-mqtt.js” and let terminal open with that, or I had to use “forever start tuya-mqtt.js”.
In either cases my CPU was up to 30/45% all the time and that caused OH to become very slow responding commands (sometimes not even responding at all).
With this script not running, my system is just very, very fast! I mean, I’ve been optimizing this for a long time now and although I have around 50/60 equipments (some 10 via Z-Wave and others via MQTT), the system simply works like a charm!
This Tuya integration was like a new challenge and I did made it… to a certain point I mean! I’ve just unninstalled nodejs and tuya-mqtt because I can’t just have this slow and unstable system.
As far as I could read on my research, Java is (very) hungry for memory due to the way this language operates. So, I mean, does JS also work that way? Is NodeJS just too much to handle for this small computing capacity?
I don’t know, I though I could just share my experience. This was just to control a single blind, so I don’t mind having to tell Alexa commands or to operate it with the remote it has, it’s just that I like to have everything integrated into OH.
@pedrolima I am running my test-environment on a Raspberry 4 and the memory/cpu usage was extremely low (couldn’t even find it on the first page of the top-output). I also created a Grafana-graph which showed me the resource usage during all my tests. In the beginning I had such a cpu-usage problem but then I updated node and after it worked fine. Can you please share your node and java version?
And yes, you are right, my bad - I forgot to add a section “How to run as a systemd service” in my how-to - sorry for that! I will write it in the next couple of minutes…
Node should, in general, be very light on memory and tuya-mqtt should not need much memory overall, although I guess everything is relative. In my environment, tuya-mqtt running on NodeJS v12.18.4 uses about 65-70MB of memory, which I think is pretty light. If you’re seeing high memory/CPU usage from tuya-mqtt, that would be unexpected for sure as I’ve worked pretty hard to make sure there are no memory leaks or other issues. CPU wise, usage for tuya-mqtt should be next to nothing, it’s extremely lightweight in this regard.
The only thing I could think of is if you device is perhaps already right at the edge of available memory, so that running a process that needs another 75MB of RAM is just too much and pushes it into swap, making everything run slower.
Finally installed into the ubuntu VM without errors.
My OH is a docker container inside the ubuntu VM. Will this installation work, or do I also need to make another kind of installation inside the container?