hobbyquaker / lgtv2

Control LG WebOS TV using node.js :tv:
MIT License
334 stars 44 forks source link

button for left/right/down/up/select #22

Open TWART016 opened 5 years ago

TWART016 commented 5 years ago

Is it possible to clickt the button for left/right/down/up/select. How can I search for commands?

MaxvandeLaar commented 5 years ago

Hi @TWART016,

I am probably a bit late to the game but for anyone else who is in the same pickle. Sending buttons isn't that difficult, however, still took me some time to find enough information about this.

So here is short example:

lgtv.getSocket('ssap://com.webos.service.networkinput/getPointerInputSocket',
    function (err, sock) {
        if (!err) {
            sock.send('button', {name: 'LEFT'}); // ok = ENTER
        }
    });

I have not yet found a list with all possible buttons but it's pretty straight forward, I did found more buttons here https://github.com/supersaiyanmode/PyWebOSTV/blob/master/pywebostv/controls.py

Mastercrrown commented 4 years ago

@MaxvandeLaar i got Problems with this my send.js Looks like:

var lgtv = require('lgtv2')({ url: 'ws://192.168.99.25:3000', clientKey: 'xxxxxxxxxxxxxxxxxxxxxxxx', timeout: '5000' });

lgtv.on('error', function (err) { console.log(err); });

lgtv.on('connect', function() { lgtv.getSocket('ssap://com.webos.service.networkinput/getPointerInputSocket', function(err, sock) { if (!err) { sock.send('button', {name: 'HOME'}); } } ); lgtv.disconnect(); });

but Always i got this error.

-----> node send.js

fs.js:636 binding.open(pathModule._makeLong(path), ^

TypeError: path must be a string or Buffer at Object.fs.open (fs.js:636:11)

What is the Problem?

can you Help me ?

Dan83 commented 4 years ago

@Mastercrrown try this code

 var lgtv = require('lgtv2')({
    url: 'ws://192.168.99.25:3000', timeout: '5000'
});

lgtv.on('error', function (err) {
    console.log(err);
});

lgtv.on('connect', function() {

    lgtv.getSocket(
            'ssap://com.webos.service.networkinput/getPointerInputSocket',
        function(err, sock) {
            if (!err) {
                sock.send('button', {name: 'HOME'});
            }
            lgtv.disconnect();
        }
    );

    //lgtv.disconnect();
});
Mastercrrown commented 4 years ago

@Dan83 Thank you very much, you made my day!!!!