Using node red to press a button inside a 3rd party node?

Is it possible to use node red to press a button inside a 3rd party node… Bare with me as its a weird one.

Im using a 3rd party node to controll the tv. Every time the tv turns off i have to repeat the process to access the controlls. I’ve looked into this extensivly to see if there’s ways to do it through LG forums and githubs for the node, but its not possible.

If you see the two images i have to click into node red, then through two menus to get to connect. If i can automate this button to be pressed everytime the tv turns on, that would be the dream. Has anyone come across anything like this before??


Another kind user has pointed me to the direction of the below, saying

If that node is GitHub - hobbyquaker/node-red-contrib-lgtv: Node-RED Nodes to control LG webOS Smart TVs 📺
When the button is pressed it makes an HTTP request to the endpoint the config creates. You can do this same thing with a http request node.

                };
        }

        Object.keys(node.users).forEach(id => {
            node.users[id].status(s);
        });
    };
}

RED.httpAdmin.get('/lgtv-connect', (req, res) => {
    if (!status || status === 'Close') {
        lgtv = require('lgtv2')({
            url: 'ws://' + req.query.host + ':3000',
            saveKey(key, cb) {
                token = key;
                RED.nodes.addCredentials(req.query.id, {
                    token: key
                });
                if (typeof cb === 'function') {
                    cb();

and

    $('#lgtv-connect').button('option', 'disabled', true);
    $('#lgtv-spinner').removeClass('hide');
    timeout = false;
    setTimeout(() => {
        timeout = true;
    }, 30000);
    pollConnection();
});

function pollConnection() {
    $.getJSON('lgtv-connect/?id=' + nodeId + '&host=' + $('#node-config-input-host').val(), data => {
        $('#lgtv-state').html(data.state);
        if (data.token) {
            $('#node-config-dialog-ok').button('option', 'disabled', false);
            $('#lgtv-spinner').addClass('hide');
            $('#node-config-input-token').val(data.token);
        } else if (timeout) {
            $('#lgtv-state').html('');
            $('#lgtv-spinner').addClass('hide');
            $('#lgtv-connect').button('option', 'disabled', false);
        } else {

Ive had a little bit of experience with http nodes and just simple http links, but not Json. This what im asking possible with the above code? If so can anyone shed a little bit more light on it or maybe point me in the right direction?

What you are asking for is not possible, as far as I know. Looking at the issues on that node it appears to be no longer supported, and apparently does not work at all with the latest node-red so I suggest there is little future in using that node.

What did the other user suggest that you do with that code? Was it here? If so please supply a link to it.

It wasn't on this forum, it was on the home assistant forum under there node red section.
Here is the LINK but before clicking on it, there's not really anything extra or useful there.

I assumed that this code would generate a html link that would be sent to an endpoint (LG) with my token which seems to always stay the same allowing me to control the tv. If i knew the link i could use it in a html request node rather than pressing the connect button every time... I've probably assumed wrong and its probably more trouble than its worth, but was just interested to see if anyone had done anything similar or had any ideas how they might tackle it.

The node hasn't been the best at being updated over the last few years and there github page is pretty bad too if you're looking for solutions. it still works at the minute and id like to think theyd jeep it going, but who knows.

Cheers

Yes there is, it shows that the suggestion is a change to the source code for the node.

No, it is suggested changes to the node itself

That is because the author is not responding.

Are you using the latest node-red? If not then are you planning to stick with the version you are using?

Oh, no it isn't it is showing the existing code in the node and telling you that you should be able to use an http request node to do the same thing. Someone would first need to understand that code though.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.