2
0

feat(gateway): allow to change the light color

Major fix on devices, set output only when no payload.sid is present
This commit is contained in:
Pierre CLEMENT
2018-01-01 20:47:30 +01:00
parent 9da0427164
commit 5732c80039
13 changed files with 292 additions and 136 deletions

View File

@@ -42,5 +42,27 @@ module.exports = {
prepareForGatewayRequest: function(node, msg) {
msg.sid = node.sid;
msg.gateway = node.gateway;
},
computeColorValue: function (brightness, red, green, blue) {
return Math.round(256*256*256*brightness) + (256*256*red) + (256*green) + blue;
},
computeColor: function (rgb) {
var blue = rgb % 256;
rgb = Math.max(rgb - blue, 0);
var green = rgb % (256 * 256);
rgb = Math.max(rgb - green, 0);
green /= 256;
var red = rgb % (256 * 256 * 256);
rgb = Math.max(rgb - red, 0);
red /= 256 * 256;
var brightness = rgb / (256*256*256);
return {
brightness: brightness,
color: { red: red, green: green, blue: blue }
};
}
}