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

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.