no more websocket calls in automation
This commit is contained in:
21
lib/ghobs.js
21
lib/ghobs.js
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user