Hi all,
I have some problems with my state topics from zigbee2mqtt. The lamps work correctly, I can set the color and brightness but I get this error back from the mqtt broker:
2021-12-15 09:35:19.824 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{x=0.3237, y=0.3322}' not supported by type 'ColorValue': {x=0.3237, y=0.3322} is not a valid string syntax
This is my thing configuration:
Thing topic Lampe_Billardtisch_MQTT "Lampe Billardtisch_mqtt" {
Channels:
Type switch : switch "Billardtisch_Gruppe_1" [stateTopic="zigbee2mqtt/Billardtisch_Gruppe", commandTopic="zigbee2mqtt/Billardtisch_Gruppe/set", transformationPattern="JSONPATH:$.state"]
Type dimmer : dimmer "Billardtisch_Gruppe_1_Dimmer" [stateTopic="zigbee2mqtt/Billardtisch_Gruppe", transformationPattern="JSONPATH:$.brightness", commandTopic="zigbee2mqtt/Billardtisch_Gruppe/set/brightness", min=0, max=254, step=1, transformationPattern="JSONPATH:$.brightness"]
Type colorRGB : color "Billardtisch_Gruppe_1_Color" [stateTopic="zigbee2mqtt/Billardtisch_Gruppe", transformationPattern="JSONPATH:$.color", commandTopic="zigbee2mqtt/Billardtisch_Gruppe/set", transformationPatternOut="JS:innrColor.js"]
Type string : color_temperature "Billardtisch_Gruppe_1_Color Temp" [stateTopic="zigbee2mqtt/Billardtisch_Gruppe", transformationPattern="JSONPATH:$.color_temp", commandTopic="zigbee2mqtt/Billardtisch_Gruppe/set", transformationPattern="JSONPATH:$.color_temp"]
}
innrColor.js
(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 = X/(X+Y+Z);
var y = Y/(X+Y+Z);
var payload = {};
payload.color = {};
payload.color.x = x;
payload.color.y = y;
return JSON.stringify(payload);
})(input)
Does somebody has the same Problem? How could I transform the color Value correctly what I get back from the broker?
Thanks in advance
Flo
- Platform information:
- Hardware: Synology VM
- OS: OH3.2M4
- Java Runtime Environment: which java platform is used and what version
- openHAB version:
- Issue of the topic: Color transformation Problem