Simple Node.js module to remote control LG WebOS smart TVs.
this is a fork of LGTV.js, heavily modified and rewritten to suite my needs.
npm install lgtv2
Subscribe to volume and mute changes and output to console:
var lgtv = require("lgtv2")({
url: 'ws://lgwebostv:3000'
});
lgtv.on('connect', function () {
console.log('connected');
lgtv.subscribe('ssap://audio/getVolume', function (err, res) {
if (res.changed.indexOf('volume') !== -1) console.log('volume changed', res.volume);
if (res.changed.indexOf('muted') !== -1) console.log('mute changed', mute);
});
});
Turn TV off:
var lgtv = require("lgtv2")({
url: 'ws://lgwebostv:3000'
});
lgtv.on('connect', function () {
console.log('connected');
lgtv.request('ssap://system/turnOff', function (err, res) {
lgtv.disconnect();
});
});
- url - websocket url of TV. default: 'ws://lgwebostv:3000'
- timeout - request timeout in milliseconds, default: 15000
- reconnect - reconnect interval in milliseconds, default: 5000
- keyFile - path for key storage. Will be suffixed with hostname/ip of TV. default: "./lgtv-"
Payload and callback params are optional.
is called when TV prompts for App authorization
is called when a connection is established and authorized
is called when trying to connect to the TV
Enable/Disable mute
Example: lgtv.request('ssap://audio/setMute', {mute: true});
Example: lgtv.request('ssap://audio/setVolume', {volume: 10});
Example: lgtv.request('ssap://media.controls/play');
Example: lgtv.request('ssap://media.controls/pause');
Show a Popup Window.
Example: lgtv.request('ssap://system.notifications/createToast', {message: 'Hello World!'});
Start an app.
Example: lgtv.request('ssap://system.launcher/launch', {id: 'netflix'});
MIT (c) 2015 Sebastian Raff