Issue with Sonoff Zigbee Bridge with Tasmota - controlling RGB strip through MQTT

Hi all,
Am using OH2.5.10 and playing around with a Tasmota flashed Sonoff Zigbee Bridge.
I have binded sensors, lights and switches to OH through MQTT and it works.

I then just bought an RGB strip and an RGB lamp - and even if turning it on/off/dimming it works, I would like to set up my “Thing” in OH to be able to control the colors of the light as well :wink:

However, I simply cannot find usuable examples of this anywhere? - it seems, that the tasmota-zigbee-mqtt bridge expects the color coding in a special format (not RGB) - but in XY format. Although there are many references to how to calculate this - I would like to ask you all if any of you have a working example of how this is set up in OH (.items and mqtt .things definitions) so that I could copy paste instead?

Hi Martin

I am already an OH3 and configure everything via UI but the link below, with some modifications, is working for me and should work also in OH 2.5.10.

This is my code, adjust the JSON.stringify to your Device and use it as JS Output Transformation

(function(i) {
    var sRGB = input.split(',');
    //sR, sG and sB (Standard RGB) input range = 0 ÷ 255
    //X, Y and Z output refer to a D65/2° standard illuminant.
    var sR = sRGB[0];
    var sG = sRGB[1];
    var sB = sRGB[2];
    
    var var_R = ( sR / 255 );
    var var_G = ( sG / 255 );
    var var_B = ( sB / 255 );
    
    var_R = Math.pow(var_R, 2.19921875);
    var_G = Math.pow(var_G, 2.19921875);
    var_B = Math.pow(var_B, 2.19921875);
    
    var_R = var_R * 100;
    var_G = var_G * 100;
    var_B = var_B * 100;
    
    var X = var_R * 0.7161046 + var_G * 0.1009296 + var_B * 0.1471858;
    var Y = var_R * 0.2581874 + var_G * 0.7249378 + var_B * 0.0168748;
    var Z = var_R * 0.0000000 + var_G * 0.0517813 + var_B * 0.7734287;
    
    var x = Math.round((X/100)*65534);
    var y = Math.round((Y/100)*65534);
    
    var payload = {};
    payload.Color = (x + "," + y);
     
    return JSON.stringify({ "Device": "0x0F6C", "send": payload });
    
    })(input)
1 Like