Created
August 13, 2019 19:42
-
-
Save voipnorm/0712a6e1e5cdbe99439aea09b017ed5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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