I own a few RGB lights including some NOUS P3Z.
Those work fine in Z2M and almost fine in OH so I think I have an issue with my transforms.
In my rules, I will sometimes use RGB changes such as:
Kitchen_Table_RGB__Color.send(new HSBType("25,64,41"))
and sometimes use temp+brightness such as:
Kitchen_Table_RGB__Temp.send(new PercentType(80))
Kitchen_Table_RGB__Brightness.send(new PercentType(80))
From what I see, using __Color
always work fine but if I change the color and then use temp+brightness, the temp goes crazy. Ie, I am setting the temp to 100% and it will jump back “on its own” down to 4%.
Could someone share what they are using if that works ?
Here is how I defined it:
Thing mqtt:topic:_MosquittoBroker:p3z_zb030 "Z2M - ZB030 - E27 RGB Kitchen table" (mqtt:broker:_MosquittoBroker) @ "Kitchen" {
Channels:
Type switch : state "State" [
stateTopic="zigbee2mqtt/ZB030/state",
commandTopic="zigbee2mqtt/ZB030/set/state"]
Type color : color "Color" [
stateTopic="zigbee2mqtt/ZB030/color",
commandTopic="zigbee2mqtt/ZB030/set",
colorMode="XYY",
transformationPattern="JS:z2m_hal550_color_in.js",
transformationPatternOut="JS:z2m_hal550_color_out.js"]
Type dimmer : brightness "Brightness" [
stateTopic="zigbee2mqtt/ZB030/brightness",
commandTopic="zigbee2mqtt/ZB030/set/brightness",
min=0, max=255 ]
Type dimmer : temp "Temp" [
stateTopic="zigbee2mqtt/ZB030/color_temp",
commandTopic="zigbee2mqtt/ZB030/set/color_temp",
min=153, max=500 ]
Type number : linkquality "Link Quality" [
stateTopic="zigbee2mqtt/ZB030/linkquality"]
}
Don’t mind my file naming that is no longer matching.
with z2m_hal550_color_in.js:
(function (x) {
var o = JSON.parse(x);
// The brightness value is received as integer 1-254 but needed as percentage 0.100
var brightness = Math.round(o.brightness / 254 * 100);
return o.color.x + ',' + o.color.y + ',' + brightness
})(input)
z2m_hal550_color_out.js:
(
function (x) {
var [x, y, brightness] = x.split(',');
x = parseFloat(x);
y = parseFloat(y);
// The brightness value is received as percentage but needed as integer 1-254
brightness = brightness * 2.54;
var payload = {
color: {
x,
y
},
brightness
};
return JSON.stringify(payload);
}
)(input)