# TCP Timeout error when using node-red-contrib-tplink-iot

**URL:** <https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784>\
**Category:** General\
**Created:** [11 November 2019 09:21 UTC](https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784 "2019-11-11T09:21:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollischulze67](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@rollischulze67](https://discourse.nodered.org/u/rollischulze67)\
**Post date:** [11 November 2019 09:21 UTC](https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784/1 "2019-11-11T09:21:58Z")

</div>

With the code below, I succeeded to realize an own function node for a tp-link HS100 plug drectly with the tplink api. In this way, I can get and set the status of the plug and have no TCP Timeout-Error-Messages anymore. In the API-documentation, the access on the plug-object was described as ".relayState ⇒ boolean".  
But now I want to realize the same thing for a tp-link HS110 plug meter (or a LB120 bulb) where the structure of the object is more complicated as I have to access (sub-)obects in the plug meter object.  
In the API-documentation, this is described as e.g. ".getPowerState([sendOptions]) ⇒ Promise.\<boolean, ResponseError\>".  
I tried a lot of days but didnt get it working.  
Could anybody give me the code or an easy understandible code example on how to realize such a function call?  
Help would be great.

const { Client } = global.get('My\_tplink\_API');

const client = new Client();

var relay\_state = 0;

const plug = client.getPlug({ host: '192.168.XXX.XXX' });

//just get status  
if (msg.payload === "getInfo")

{  
const plug = client.getDevice({ host: '192.168.XXX.XXX' }).then((device)=\>{  
msg.payload = Number(device.relayState);  
node.send(msg);

```auto
 });

```

}  
//plug has been activated  
else if (msg.payload === true)  
{  
plug.setPowerState(true);  
relay\_state=1;  
msg.payload = relay\_state;  
return msg;

```auto
} else if (msg.payload === false)
    {
        plug.setPowerState(false);
        relay_state=0;
        msg.payload = relay_state;
        return msg;
    }

```

msg.payload = relay\_state;  
return;

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 November 2019 11:35 UTC](https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784/2 "2019-11-11T11:35:25Z")

</div>

Did you ever try the [node-red-contrib-tplink-iot](https://flows.nodered.org/node/node-red-contrib-tplink-iot) node?

---

<div class="post-metadata">

**Author:** ![rollischulze67](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@rollischulze67](https://discourse.nodered.org/u/rollischulze67)\
**Post date:** [11 November 2019 14:51 UTC](https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784/3 "2019-11-11T14:51:22Z")

</div>

Yes, and there is the problem. Unfortunately, the "ready to use" smart bulb and the smart plug nodes of this package send messages of their own that I can not stop or control. The results are error messages in the console window of my node red installation which lets the processor load climb more and more until my system "collapses". So I searched and found this function-node solution for the HS100 but for the HS110 and the LB120 tp-link products, my programming- / coding-skills are insufficent. I would be thankfull for further help.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 November 2019 15:16 UTC](https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784/4 "2019-11-11T15:16:28Z")

</div>

> [@rollischulze67](#):
>
> Unfortunately, the "ready to use" smart bulb and the smart plug nodes of this package send messages of their own that I can not stop or control.

Well if adjusting the poll interval and filtering out unwanted messages won't work, you will hqve to hope someone else will chime in on this issue

---

<div class="post-metadata">

**Author:** ![rollischulze67](https://avatars.discourse-cdn.com/v4/letter/r/7ab992/32.png) [@rollischulze67](https://discourse.nodered.org/u/rollischulze67)\
**Post date:** [15 November 2019 08:00 UTC](https://discourse.nodered.org/t/tcp-timeout-error-when-using-node-red-contrib-tplink-iot/17784/5 "2019-11-15T08:00:39Z")

</div>

Thanks for your research.

No other hints or help?
