2
0

feat(color): add color picker and brightness range on set color action

This commit is contained in:
Pierre CLEMENT
2018-01-02 14:20:23 +01:00
parent 24ef7012f9
commit e504a00de9
3 changed files with 30 additions and 4 deletions
@@ -80,11 +80,15 @@ module.exports = function(RED) {
function XiaomiActionGatewayLight(config) {
RED.nodes.createNode(this, config);
this.gateway = RED.nodes.getNode(config.gateway);
this.color = RED.nodes.getNode(config.color);
this.brightness = RED.nodes.getNode(config.brightness);
var node = this;
node.on('input', function(msg) {
if(node.gateway && node.gateway.sid && node.gateway.key && node.gateway.lastToken) {
var rgb = miDevicesUtils.computeColorValue(msg.brightness, msg.color.red, msg.color.green, msg.color.blue);
var color = msg.color || node.color;
var brightness = msg.brightness || node.brightness;
var rgb = miDevicesUtils.computeColorValue(brightness, color.red, color.green, color.blue);
msg.payload = {
cmd: "write",
data: {