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

**URL:** <https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678>\
**Category:** General\
**Created:** [24 October 2021 19:08 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678 "2021-10-24T19:08:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdr2404](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gdr2404/32/36273_2.png) [@gdr2404](https://discourse.nodered.org/u/gdr2404)\
**Post date:** [24 October 2021 19:08 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678/1 "2021-10-24T19:08:00Z")

</div>

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??

 ![01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e6c798dd4291357571698b93f6813e75d8e42de6.jpeg)  
 ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bbc23315971d1044234772a9df2c68111fa8902b.jpeg)

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 📺](https://github.com/hobbyquaker/node-red-contrib-lgtv)  
> 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.

```auto
                };
        }

        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

```auto
    $('#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?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 October 2021 09:18 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678/2 "2021-10-25T09:18:05Z")

</div>

What you are asking for is not possible, as far as I know. Looking at the [issues](https://github.com/hobbyquaker/node-red-contrib-lgtv/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.

---

<div class="post-metadata">

**Author:** ![gdr2404](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gdr2404/32/36273_2.png) [@gdr2404](https://discourse.nodered.org/u/gdr2404)\
**Post date:** [25 October 2021 11:56 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678/3 "2021-10-25T11:56:11Z")

</div>

It wasn't on this forum, it was on the home assistant forum under there node red section.  
Here is the [LINK](https://community.home-assistant.io/t/useing-node-red-to-press-a-button-inside-a-3rd-party-node/349324/3) 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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 October 2021 12:33 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678/4 "2021-10-25T12:33:58Z")

</div>

> [@gdr2404](#):
>
> there's not really anything extra or useful there.

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

> [@gdr2404](#):
>
> I assumed that this code would generate a html lin

No, it is suggested changes to the node itself

> [@gdr2404](#):
>
> ithub page is pretty bad too if you're looking for solutions.

That is because the author is not responding.

> [@gdr2404](#):
>
> it still works at the minute

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 October 2021 13:03 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678/5 "2021-10-25T13:03:31Z")

</div>

> [@Colin](#):
>
> Yes there is, it shows that the suggestion is a change to the source code for the node.

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 December 2021 13:04 UTC](https://discourse.nodered.org/t/using-node-red-to-press-a-button-inside-a-3rd-party-node/52678/6 "2021-12-24T13:04:26Z")

</div>

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