no more websocket calls in automation

This commit is contained in:
Chris Ham
2018-09-25 15:32:26 -07:00
parent 641b708ce5
commit 4d153373d1
2 changed files with 39 additions and 92 deletions

View File

@@ -97,6 +97,17 @@ function GHOBS(config) {
return this.websocket.setSceneItemProperties({"item": item, "scene-name": scene, "visible": visible});
};
this.toggleVisible(item) => {
return new Promise((resolve, reject) => {
this.websocket.getSceneItemProperties({"item": item})
.then(data => {
let newVisibility = !data.visible;
this.websocket.setSceneItemProperties({"item": item, "visible": newVisibility}).then(resolve);
})
.catch(reject);
});
}
this.show = (item, scene) => {
return this.setVisible(item, scene, true);
};
@@ -104,6 +115,16 @@ function GHOBS(config) {
this.hide = (item, scene) => {
return this.setVisible(item, scene, false);
};
this.switchToScene(scene) => {
return new Promise((resolve, reject) => {
if (this.currentScene === scene) {
resolve(true);
}
this.websocket.setCurrentScene({"scene-name": scene}).then(resolve).catch(reject);
});
};
};
module.exports = GHOBS;