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

@@ -21,30 +21,32 @@ module.exports = function(RED) {
var payload = msg.payload;
// Input from gateway
if (payload.sid == node.sid && ["switch", "sensor_switch.aq2"].indexOf(payload.model) >= 0) {
var data = payload.data;
miDevicesUtils.setStatus(node, data);
if (payload.sid) {
if (payload.sid == node.sid && ["switch", "sensor_switch.aq2"].indexOf(payload.model) >= 0) {
var data = payload.data;
miDevicesUtils.setStatus(node, data);
if (node.output == "0") {
node.send([msg]);
} else if (node.output == "1") {
var status = null;
if (node.output == "0") {
node.send([msg]);
} else if (node.output == "1") {
var status = null;
if (data.status) {
status = {"payload": data.status};
}
node.send([status]);
} else if (node.output == "2") {
var status = null;
if (data.status) {
status = {"payload": data.status};
}
node.send([status]);
} else if (node.output == "2") {
var status = null;
if (data.status && data.status == "click") {
status = {"payload": mustache.render(node.outmsg, data)}
node.send([[status],[]]);
}
if (data.status && data.status == "click") {
status = {"payload": mustache.render(node.outmsg, data)}
node.send([[status],[]]);
}
if (data.status && data.status == "double_click") {
status = {"payload": mustache.render(node.outmsgdbcl, data)}
node.send([[],[status]]);
if (data.status && data.status == "double_click") {
status = {"payload": mustache.render(node.outmsgdbcl, data)}
node.send([[],[status]]);
}
}
}
}