11.04.2022, 06:06
Set Additional classes to rgbw and add this to Custom JS:
Icon will be hidden, the square size will be the same as the icon size. RGBW value is converted to RGB.
Code:
$(function(){
$('.rgbw').each(function(index, el) {
var $el = $(el);
var addr = $el.data('status-object');
$el.find('img').css('visibility', 'hidden');
grp.listen(addr, function(object) {
var value = object.value;
var r = ((value >> 24) & 0xFF) / 255;
var g = ((value >> 16) & 0xFF) / 255;
var b = ((value >> 8) & 0xFF) / 255;
var w = (value & 0xFF) / 255;
var a = 0.6 * (1 - (1 - w) * (1 - w));
var rgb = [
Math.round(((1 - a) * r + a) * 255),
Math.round(((1 - a) * g + a) * 255),
Math.round(((1 - a) * b + a) * 255)
];
$el.css('background', 'rgb(' + rgb.join(',') + ')');
});
});
});
Icon will be hidden, the square size will be the same as the icon size. RGBW value is converted to RGB.