Sending and Listening to TCP

Hello -

I have a Vantage Qlink lighting system that has what they call an IP Enabler. Through this enabler a system can send and receive serial text commands to turn light on and off. I currently have OpenHab connected to it so that lighting can be controlled through it.

I'd like to move this to Node Red and am running into trouble.

I have created a flow that contains both a TCP IN and TCP Request node in it. If I inject a String such as SW 1 74 2 1 that will turn my Hallway lights on (this works as expected) If Node Red hears SW 1 74 2 0 I will want it to trigger the Hallways lights off (the methodology for turning the light off has been figured out)

What I am having trouble with is having a listener, listen all the time and then being able to send a command. It seems I can only have one TCP node connected.

This is what I have constructed.

and as you can see the listener is connected, yet the sender is reporting back a connection error.

I believe OpenHab keeps a connection open that it can both listen and send on....(OpenHab is not running when I test this scenario - so it's not conflicting with the connection)

Is there another way I should be constructing this?

Both nodes have the IP address and Port of the IP Enabler.

Any suggestions would be greatly appreciated.

Squid :squid:

Hi Kidsquid

Can you attach the flow using the image button

[{"id":"952ce6dd.72e108","type":"tab","label":"TCP","disabled":false,"info":""},{"id":"df170615.2bfed8","type":"inject","z":"952ce6dd.72e108","name":"HALLWAY LIGHTS","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"VSW!1 90 1 6\\r\"","payloadType":"json","x":151.5,"y":73,"wires":[["db582df1.2c4fd"]]},{"id":"cec078c3.06cf78","type":"debug","z":"952ce6dd.72e108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":733.5,"y":180,"wires":[]},{"id":"db582df1.2c4fd","type":"tcp request","z":"952ce6dd.72e108","server":"9.9.9.9","port":"3040","out":"time","splitc":"0","name":"TCP SEND","x":348.5,"y":77,"wires":[["9aef25fe.018578"]]},{"id":"9aef25fe.018578","type":"function","z":"952ce6dd.72e108","name":"CONVERT HEX TO STRING","func":"msg.payload = Buffer.from(msg.payload,\"hex\").toString()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":626.5,"y":76,"wires":[["cec078c3.06cf78"]]},{"id":"4905be31.615c6","type":"tcp in","z":"952ce6dd.72e108","name":"TCP LISTEN","server":"client","host":"9.9.9.9","port":"3040","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":290.5,"y":162,"wires":[["9aef25fe.018578"]]}]

Have you tried TCP IN + TCP OUT?

There is a demo here

Or the other way is to use the tcp request node only and set it to leave the connection open, so that it remains listening for incoming messages.

So I tried setting Keep the connection open.....yet when I trigger a light manually (from the wall switch) I do not see anything in the debug window.

Any other possible solutions?

in request mode you need to send at least something to open it up in the first place... after that it should stay open. If you aren't seeing anything then indeed try the in plus out node way - do you ever receive anything ?

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