Skip to content

GermanBluefox/lgtv2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LGTV2

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.

Installation

npm install lgtv2

Usage Examples

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();
    });
    
});

API

options

  • 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-"

methods

request(url [, payload] [, callback])

Payload and callback params are optional.

subscribe(url, callback)

events

prompt

is called when TV prompts for App authorization

connect

is called when a connection is established and authorized

connecting

is called when trying to connect to the TV

close

error

Commands

api/getServiceList

audio/setMute

Enable/Disable mute

Example: lgtv.request('ssap://audio/setMute', {mute: true});

audio/getStatus

audio/getVolume

audio/setVolume

Example: lgtv.request('ssap://audio/setVolume', {volume: 10});

audio/volumeUp

audio/volumeDown

com.webos.applicationManager/getForegroundAppInfo

com.webos.applicationManager/launch

com.webos.applicationManager/listLaunchPoints

com.webos.service.appstatus/getAppStatus

com.webos.service.ime/sendEnterKey

com.webos.service.ime/deleteCharacters

com.webos.service.tv.display/set3DOn

com.webos.service.tv.display/set3DOff

com.webos.service.update/getCurrentSWInformation

media.controls/play

Example: lgtv.request('ssap://media.controls/play');

media.controls/stop

media.controls/pause

Example: lgtv.request('ssap://media.controls/pause');

media.controls/rewind

media.controls/fastForward

media.viewer/close

system/turnOff

system.notifications/createToast

Show a Popup Window.

Example: lgtv.request('ssap://system.notifications/createToast', {message: 'Hello World!'});

system.launcher/close

system.launcher/getAppState

system.launcher/launch

Start an app.

Example: lgtv.request('ssap://system.launcher/launch', {id: 'netflix'});

system.launcher/open

tv/channelDown

tv/channelUp

tv/getChannelList

tv/getChannelProgramInfo

tv/getCurrentChannel

tv/getExternalInputList

tv/openChannel

tv/switchInput

webapp/closeWebApp

License

MIT (c) 2015 Sebastian Raff

About

Control LG WebOS TV using node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%