Skip to content

Instantly share code, notes, and snippets.

@DGZN
Created May 24, 2017 17:29
Show Gist options
  • Save DGZN/248978ae0eabbba8f238419f2783687e to your computer and use it in GitHub Desktop.
Save DGZN/248978ae0eabbba8f238419f2783687e to your computer and use it in GitHub Desktop.
Samsung Smart TV Remote
'use strict'
var SamsungRemote = require('samsung-remote');
var remote = new SamsungRemote({
ip: '10.0.1.36', // required: IP address of your Samsung Smart TV
port: '7676'
});
const status = (cb) => {
// check if TV is alive (ping)
}
const send = (key) => {
remote.send('KEY_VOLUP', function callback(err) {
if (err) {
throw new Error(err);
} else {
console.log("VOLUME UP!")
}
});
}
const getStatus = (cb) => {
remote.isAlive(function(err) {
if (err) {
cb({
online: false,
status: 'Online',
msg: `IT DOESN'T LOOK LIKE YOUR TV IS ONLINE`
})
return;
}
cb({
online: true,
status: 'Online',
msg: `TV IS ONLINE AND YOU ARE CONNECTED`
})
});
}
getStatus((status) => {
if ( ! status.online ) {
console.error(status.msg);
return;
}
console.log(`[${status.status}] ${status.msg}`)
send('KEY_HOME')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment