feat(gateway): addset light and play sounds
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user