2
0

feat(gateway): addset light and play sounds

This commit is contained in:
Pierre CLEMENT
2018-02-21 22:01:31 +01:00
parent 7bff50da16
commit b6e311965a
18 changed files with 280 additions and 667 deletions

View File

@@ -1,5 +1,6 @@
import {Red, NodeProperties} from "node-red";
import {Constants} from "../constants";
import {GatewayServer} from "../../devices/GatewayServer";
export default (RED: Red) => {
class GatewayOut {
@@ -11,7 +12,22 @@ export default (RED: Red) => {
protected setMessageListener() {
(<any> this).on("input", (msg) => {
if (msg.hasOwnProperty("payload") && msg.hasOwnProperty("gateway")) {
msg.gateway.gateway.send(msg);
let gateway = GatewayServer.getInstance().getGateway(msg.gateway.sid);
if(gateway) {
if (msg.payload.cmd) {
gateway.send(msg);
}
else if (msg.payload.action) {
switch (msg.payload.action) {
case 'setLight':
gateway.setLight(msg.payload.brightness, msg.payload.color);
break;
case 'playSound':
gateway.playSound(msg.payload.mid, msg.payload.volume);
break;
}
}
}
}
});
}