Skip to content

Instantly share code, notes, and snippets.

@voipnorm
Created August 13, 2019 19:42
Show Gist options
  • Save voipnorm/0712a6e1e5cdbe99439aea09b017ed5b to your computer and use it in GitHub Desktop.
Save voipnorm/0712a6e1e5cdbe99439aea09b017ed5b to your computer and use it in GitHub Desktop.
const xapi = require('xapi');
var IP = "<IP of HDMI Switch>";
function switchHDMI(source){
var url = `http://${IP}/aj.html?a=command&cmd=x${source}AVx1`;
xapi.command('HttpClient Get', {Url: url})
.then((data) => {
console.log(data)
}).catch(err => {console.log(err)})
}
function listenToGui() {
xapi.event.on('UserInterface Extensions Widget Action', (event) => {
const msg = `id=${event.WidgetId} / type=${event.Type} / value=${event.Value}`;
console.log(msg);
switchHDMI(event.Value)
});
}
listenToGui();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment