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

I’m having such a headache with all this… I’ve tried all the other methods for getting these keys and hit a dead end and now I’m getting the same thing here.

I’ve followed the steps up to and including installing Root Certificate Manager, but I can’t figure out where the QR code is coming from. All I can see in RCM is a list of 150-odd certs, all of which I can view or download to SD card, but no QR codes to be found anywhere. What am I missing??

EDIT Scratch that, I was able to locate the keys using a different root folder explorer. Phew!

Has anyone managed to get this working on a Synology NAS, by any chance? I’m a bit of a noob at this Linux thing, but I’ve tried to follow the process (the 2.4x option, as I’m running 2.5) and the MQTT broker just seems to stay offline, meaning the thing I added won’t connect either.

When I was installing the various elements (the “npm” commands) I saw a lot of WARN messages come through which, as a Windows person made me think, “Hmm, that can’t be good.” This is an example of what I mean:

 root@SERVER1:/volume1/public/openHAB/scripts/tuya-mqtt# npm install
 npm WARN engine mqtt@3.0.0: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.18","npm":"2.15.11"})
 npm WARN engine p-timeout@3.1.0: wanted: {"node":">=8"} (current: {"node":"0.12.18","npm":"2.15.11"})
 npm WARN engine p-retry@4.1.0: wanted: {"node":">=8"} (current: {"node":"0.12.18","npm":"2.15.11"})
 npm WARN engine p-finally@1.0.0: wanted: {"node":">=4"} (current: {"node":"0.12.18","npm":"2.15.11"})
 npm WARN engine retry@0.12.0: wanted: {"node":">= 4"} (current: {"node":"0.12.18","npm":"2.15.11"})
 npm WARN engine readable-stream@3.5.0: wanted: {"node":">= 6"} (current: {"node":"0.12.18","npm":"2.15.11"})

And when I try to run node tuya-mqtt.js, I get this output:

root@SERVER1:/volume1/public/openHAB/scripts/tuya-mqtt# node tuya-mqtt.js
/volume1/public/openHAB/scripts/tuya-mqtt/tuya-mqtt.js:2
const mqtt = require('mqtt');
^^^^^
SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Any advice would be hugely appreciated :slightly_smiling_face:

Hello,

thanks for work!
It is means that i can use every tuya device this way&
For example https://www.amazon.de/gp/product/B07VW8D7PB

Thanks!

if i have a wall switch of two gangs how i can cantrolle the second botton

I used version 3.6.1 from here: https://apkpure.com/smart-life-smart-living/com.tuya.smartlife/download/70-APK and find localkey, that work.
Also, to read XML file, I coped file to computer with help of FM tab on BlueStacksTweaker.

1 Like

I have a tuya controlled ceiling fan.

Anybody know how to control the Light and fan using this method.

The light is ON/OFF, Colour temp (warm/cool), and fan is ON/OFF with 6 speed settings.

Hi, could you share your configuration for the switches (https://www.aliexpress.com/item/33001282012.html?spm=a2g0s.9042311.0.0.2c594c4dHWKc2t)?
I use this same but I am not able to set up it in OpenHab

Hi rupert,

I just bought a new RPi4 and reconfigure devices.

I using OpenHabian
OH 2.5
MQTT binding
Mosquitto 3.1 (do not use embeded MQTT from Openhab, please install from openhabian-config. )
Tuya-mqtt version3.3 (run on node.js, see more on GitHub)

Make MQTT Generic Topic for each physical switch box and channel/item for each button. On/Off custom vale should be { “dps” : 1, “set” : 1 } (dps for a button eg. 1,2,3. set is 1 for on 0 for off.)

Hi - I’m trying to use the BlueStacks approach to get the outlined at the start of this thread, having failed with TuyaConvert or other methods to get the LocalKey. However the only Wifi network BlueStacks can see is one it’s created itself - strangely enough named “BlueStacks” !

How do I either (a) obtain the password for this wifi network (which SmartLife needs), or add the wifi network on which the windows PC hosting BlueStack is running?

Hi NarathornBanvorn
I am trying to configure it on RPi4 also,
could you tell me if I set the parameters correctly? I am not able to set the configuration to work correctly maybe you can give me some hints.

Hi Rupert. Here is my setting. It seems like you miss the double quote.

Phew - fixed it. Added the device through SmartLife on my phone, and was then able to get the un-encrypted details through a rooted Bluestacks (with a previous version of Smartlife from the apk repo). After then tussling with the right version of tuya-mqtt (needed the more recent version for MQTT 3.3) all is working. Thanks to all the great work and pointed from @HolgiHab, @tsightler, and @Fiftiz

I’m a beginner following this guide but I got as far looking for the Local Key but the .xml file only contained;

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>

Apparently Smart Life no longer store the local key in that file. Does anyone know how I can now find the Local Key?

UPDATE: I tried installing Smart Life V2.8.1 but it won’t allow you to login until you update.

Hi All,

Looking for some help getting my Tuya sockets to work properly. Been through most of the thread here trying to understand and have reached the following point:

OH 2.5 on a raspberry pi4
Got the Local key for my socket
Installed the tsightler version of Tuya-MQTT
Setup the Openhab MQTT binding / broker / things
Set up a switch channel for command and state elements with
Tuya/socket/device ID/local key/IP address
Left the custom on/off values blank.

What happens is once I start the script, I can turn the socket on, but then not off.
If I re-start the script with the socket on, I can turn it off, but not on again!
I’ve run the script with debug and it looks like the script just doesn’t send the second command for some reason.
I also can control the socket reliably with the tuyaapi cli commands on dps 1

Has anyone encountered this before?

I’ve tried the version 3.3 format and it doesn’t seem to work for these sockets, although I may be formulating something wrong as I get ”bad format” reports in the debug.

The sockets are Teckin energy monitoring ones. The square version.
Also running into issues trying to start the script as a service, but I’ll leave that question until I can get the sockets switching reliably

Mike

@Ravelymg I had the same problem, look at my comment here


Devices needs to be disconnected every time after command. Found the solution in a fork of the fork.
Now it works like expected.

Mike,

How did you find your Local ID?

Lester

@Fintasys Thanks!

Worked a treat. Full control.

Now onto working out how to extract the Volts/Power dps values…

Mike

@lesterb

I used the rooted Bluestacks method. Took me a while though, first time I’d encountered it.

Had to use the apk mirror to get an old version of the SmartLife app (3.6.1 I think… picked as someone further up the thread mentioned it) to get the right data in the file. Also tried the Packet Capture method, but just got gunk.

If you’re having a specific issue, try me. I’m no expert, but had to jump through a lot of hoops to get the numbers out!

Mike

1 Like

Thanks Mike,

I tried both. I think they have changed it lately so that you have to upgrade to the encrypted version before it will let you log in. Thanks anyway.

Lester

Interesting… I only did it last week. Has it changed over the weekend? Or perhaps it relates to how long you’ve had an account? I’ve had the account since November.