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

Hi @worstenbrood nice writing… I use textual config and an external mqtt broker, but have managed to get everything configured so far… I only have one question maybe you can answer this?!
in your guide you add two channels:

• Mode (switch)
   Command: tuya/lsc-a60-rgb-cct_1/dps/21/command
   State: tuya/lsc-a60-rgb-cct_1/dps/21/state
   Off value: colour
   On value: white
   Has another value: scene

• Scene (string)
  State: tuya/lsc-a60-rgb-cct_1/dps/25/state
  Command: tuya/lsc-a60-rgb-cct_1/dps/25/command 

this looks like this in my textual config:

            Type switch : mode "Mode" [
                stateTopic="tuya/Smart-Bulb_01/dps/21/state",
                commandTopic="tuya/Smart-Bulb_01/dps/21/command",
                On="white",
                Off="colour"
            ]
            Type string : scene "Color Scene" [
                stateTopic="tuya/Smart-Bulb_01/dps/25/state",
                commandTopic="tuya/Smart-Bulb_01/dps/25/command"
            ]

but what is missing is the linking to the scene channel…

   Has another value: scene

any idea how this would look like in textual config?

I had a look at the Documentation but this doesn’t seem to cover how to link these channels in text files.

Is this neccesary at all? Would be nice to get my tuya bulbs controlled by openhab :wink:

thanks

Edit:
Ok, I got everything running without the channel linking… no problem for me because I don’t use these preconfigured tuya lightscenes at all.

Hi All, new to this thread but not to Openhab. Just trying to integrate Tuya into my system - and this is the 3rd method I’ve tried :wink:

I’m so close with this one! But I think my issue is that I have all my devices behind a Tuya hub. So the only device with wifi is the hub itself, my other devices need the hub to access wifi.

Anyone know of a way to get to those sub-devices using this method. I’ve tried accessing them directly, and also most recently found a potential protocol for referencing sub-devices via the gateway for another API tuyaDAEMOM global.alldevices · msillano/tuyaDAEMON Wiki · GitHub

So I was trying…

[
  {
    name: 'Zigbee Hub',
    id: 'hhhhhhhhh',
    key: 'kkkkkkkkkk1',
    subDevices: [
      {
        name: 'Pool Blind 2',
        id: 'bbbbbbbbbbbb',
        gateway: 'hhhhhhhhh',
        cid: 'id1ididididididid'
      },
      {
        name: 'LED Strip',
        id: 'bf78XXXXXXXXXtws',
        gateway: 'hhhhhhhhh',
        cid: 'id2ididididididididi'
      }
    ]
  }
]

The hub is connecting fine, but the sub-devices just time-out. Should i just give up on this one? Next step i think is to Flash the Zigbee devices!

Are these actually Tuya or Zigbee devices? I know there are Tuya devices out there which aditionally use the Zigbee standard. If that is the case, aren’t you able to use a Zigbee-Bridge and get rid of that Tuya crap?? I thought if devices (even tuya) are able to use the Zigbee standard you don’t have to use the Smartlife App.

…btw, never heard of a tuya-bridge, are you sure you’re not using a Zigbee-bridge?

Just a guess but if this is the case you should be able to use it with the Zigbee-Binding if I’m not mistaking…

I’m not sure if this works

The devices have Tuya/Zigbee logos on the boxes. The hub is a cheap one from Amazon, says Zigbee 3.0 Hub, but has Zigbee and Tuya logos all over it - the brand is Yueyang.

Think this is a pretty standard Zigbee 3.0 hub? (sorry I see Amazon link says ‘door sensor’ but that’s just one of the items you can buy in this listing - also can buy the hub)

I have tried the Zigbee binding, but this needs a Zigbee co-ordinator USB dongle in my RPI. I purchased the Sonoff Zigbee 3.0 Plus dongle. Had some success, but the singnal was really weak around my house, so not sure if its going to work for me without buying loads of smart plugs or something similar to boost the signal.

Yeah that’s the downside of the low energy zigbee devices… all battery powered devices have a lack of range and can’t be used as mesh extenders. So you’re right, without using direct powered devices there are no extenders in your setup.

Sorry, can’t help with the Tuya Subdevice configuration…

Edit:
I don’t know if you like some electro-tinkering but if so maybe this link is something for you to inexpensively extend your zigbee-mesh.

There are a few similar projects out there… so maybe you find a solution that satisfies your needs…

Even the picture scared me :wink: I’m actually thinking of going a slightly different route. My main reason for looking at Zigbee/Tuya was for roller-blinds. Have got a couple of Zemismart Zigbee blinds from China - but they are also RF. So for 20euro I’m going to try a Sonoff RF to WiFi converter.

If I can get this working I can then use something like MQTT to instruct as per the below.

The RF signals are pretty reliable in these blinds and I have the RF remote to learn the commands - if i can get this working i can rid myself of Zigbee and Tuya alltogether!

Describe the bug
Hi, im currently on raspberry pi and using OpenHab.
I have setup the tuya-mqtt in my folder /opt/tuya-mqtt.
The Pi creates a hotspot with Hostapd via WiFi.
He only gets internet access when I connect him to the Ethernet (it’s all supposed to be like that, so it’s correct).
My Tuya Bulb then connects to the hotspot and can also be pinged.
The MQTT-Broker and my LED are already setup and working. → See config file
I have downloaded mqtt-explorer to track the trafic on my broker topic and noticed that every time I connect my Raspberry pi to the Internet, a topic called “Homeassistant” and several subtopics are created.
I also noticed that my LED only works when the mentioned topics are created and the status is = online…
If the status = offline, the LED cannot be controlled or pinged.
It should be mentioned that the pi creates the mentioned topics after booting and after that the status goes online for several seconds. (LED can be controlled during this time without any problems)
The status then goes offline again and the LED cannot be controlled.
Important: Only if the Pi had Internet access while booting up it will create the topics!

Expected behavior
The problem is that I actually want to control the LED completely locally and without any internet access.
When booting up, the LED should be easily controlled.

Screenshots

Versions:

  • Raspbian debian buster v. 10
  • OpenHab 2.5.8
  • MQTT 2.5.8

Additional context
Maybe someone can tell me if the port (1884) is correct or whether there is a specific port that is used for the Broker.
Also, it would be nice if someone could tell me what the status stands for and if it’s normal for me to need an internet connection while booting the Pi.

Thanks for your help!

@Dan sorry for the late reply but i switched to HA in the mean time. The values of the scenes (like you can see if you run tuya-mqqt in debug and use the official app to switch) are some hexadecimal values i didn’t spend time on to decode.

I used to get Tuya MQTT running smoothly with OH3.3 and Mosquitto on Pi4. Today after reinstalling I can’t get Tuya MQTT running as before.
When running “node tuya-mqtt.js” it stucks and I have to press CTRL-C to break, but I can run “DEBUG=* node tuya-mqtt.js” and see it’s working (ping devices, receive payloads…).
Please help me fix this!

I think I may have the same issue although I have just installed OH3 and tuya-mqtt. I have used MQTT Explorer to check things are getting to my MQTT broker and they are, but the dps state looks like this
{
“1”: “KU\u001eFp�>j~\u001a�zL�m\u0015�Y�YZdH(\u0015��\f�M��”
}

Hello !!
I am from France and I would like to thank all the contributors who share their knowledge here, it has helped me a lot!
I will try to explain my problem as clearly as possible.

  • Environment :
    Openhab 3 image (openhabian) installed in Rpi 3
    tuya-mqtt by AgentK installed following this topic and this one (Tuya devices to Openhab via MQTT - a working solution (without flashing)!)
    Everything works fine (monitor topics with mqtt explorer) with a Wifi 2ch Dimmer Switch (no battery) !

  • Problem :
    I am trying to install a temperature/humidity Wifi sensor (wireless, with battery) in the same way.
    I don’t know its brand, but it looks exactly like this model :
    https://www.amazon.fr/Oewnvmd-Intelligent-TempéRature-Intelligente-Travailler/dp/B0B8JD59Y7
    No problem to connect it with Tuya App and get id/key from tuya cli wizard and get temp/hum from Tuya App or from Tuya log siteweb.
    However, It seems it is not staying connected all the time (only when Temp/Hum change). I think this is normal to save battery ?

    My probleme is I have lots of difficulties to get its topics state.
    I can retrieve data but it is very random.
    Example, I analyse the log of the Tuya iot site, I see my temperature change 3 times in one hour (19°C, 19,5°C, 20°C) (each time the sensor connects/disconnects to the wifi)
    But on my server mqtt doesn’t get all the values directly, for example only the value 19,5°C. Even after 3 hours, I still have 19.5°C on openhab.

When I try to launch tuya-mqtt in DEBUG mode, I can see it try to connect to the ID, but it don’t find it. I think it manages to find it from time to time, but I haven’t seen it with my own eyes (it’s so long or random).

  • My assumption:
    The sensor only stays connected for a few seconds, and if the tuyamqtt doesn’t try to connect at that time then we miss the data.

So, how can I manage this type of device which is not always connected to wifi with tuyamqtt ?

Thank you to take the time to read me. I hope that is clear. Don’t hesitate to ask me for more information.
Regards.

Hello,
did you ever sort out how to get Tuya-mqtt to read subdevices behind a tuya zigbee gateway?