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

As per the following discussion,

the proper solution to control the tuya brightness should be to add { “dps”: 2, “set”: %d} to the Outgoing Value Format (OVF) but it seems that the %d is not properly processed by OVF at that stage.

The temporary workaround is to not use OVF but to add the following Javascript transform

(function(brightness) {
    var tuyaobj = {"dps": 2, "set": Math.floor(brightness)};
    var data = JSON.stringify(tuyaobj);
    return data;
})(input)

JSONPATH:$.2 must also be added to the channel “Incoming value transformations” to process properly the dimmer state.
The complete channel set up is:

with the following item setup (including Alexa control for my specific need)

Dimmer TableLight “Table Light [%d %%]” {channel=“mqtt:topic:d2cfb0fd:Dimmer”, alexa=“Lighting”}

1 Like