HI I reaching out to get some help with setting up formatting on the a send and receive node for a device

The device communicates through an IP connection using an ASCII protocol.

protocol will allow control and monitoring of
• On/Off
• Mode
• Set Point Temperature
• Room Temperature
• Fan Speed

I want to create a node that I can link to MQTT for each function
ec: On/Off

Send MQTT[payload AirConON>On/Off>ASCII>TCPout:
Receive TCPin:>ASCII>MQTT[payload AirConON

I presume once I can get a send and response for 1 function I can duplicate it for the other functions.
I have a attached
Air-Con ASCII set.pdf (434.3 KB)
the pdf for the units WMP protocol.

I have been playing around with this for some time and can not get any response from the unit.

Start simple. Add an inject node with the required string, send that to a TCP request node then attach that to a debug node.

Get that working then it's a simple matter of generating ASCII strings from your mqtt data.

Hi Have done this so far , But I can get any respose from WMP device

When I inject ID

I get in the debug

Function Node has this

ascii = [];

for (var i = 0; i < msg.payload.length; i ++)

return {payload:ascii}

Delete the function node and set the inject to send a string of ID\r

Do you get a reply?

No Reply,

I followed your investigation since I find it interesting.
Looking at the very last proposal and test, I thought this should work, but obviously it didn't.

The protocol specification is quite easy, therefore I tested with something similar, WHOIS.

Using the shell I did the following:

telnet 43
and after the connection success, I sent the string "" and got the correct answer.

Now the same thing with node-red. Here is the flow, very similar to what has been tried here:

[{"id":"1664b053.a37ae","type":"tcp request","z":"635b69bb.594868","server":"","port":"43","out":"time","splitc":"1000","name":"","x":410,"y":240,"wires":[["53da295d.1e4db8"]]},{"id":"53da295d.1e4db8","type":"debug","z":"635b69bb.594868","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":240,"wires":[]},{"id":"adf7805c.4aa278","type":"inject","z":"635b69bb.594868","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":150,"y":240,"wires":[["1664b053.a37ae","58b754fc.b65434"]]},{"id":"58b754fc.b65434","type":"debug","z":"635b69bb.594868","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":390,"y":200,"wires":[]}]

I tested all the options in the TCP node, nothing worked. No reply at all. Ever.

There are a number of explanations:

  • I did it wrong
    -> I should keep my fingers away from this topic and let the experts help
  • The TCP node is wrong
    -> I should keep my fingers away and let the experts dig deeper

Either way, I'm of no real help here, I'm sorry to say.

Ha. I got at least my example running. This might or might not help in this case here:

In the inject node, I initially used "String" as inject format type for msg.payload.
It works, if I select "JSON".

Working example is here:

[{"id":"1664b053.a37ae","type":"tcp request","z":"635b69bb.594868","server":"","port":"43","out":"sit","splitc":" ","name":"","x":450,"y":240,"wires":[["53da295d.1e4db8"]]},{"id":"53da295d.1e4db8","type":"debug","z":"635b69bb.594868","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":240,"wires":[]},{"id":"adf7805c.4aa278","type":"inject","z":"635b69bb.594868","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"\\n\"","payloadType":"json","x":190,"y":240,"wires":[["1664b053.a37ae","58b754fc.b65434"]]},{"id":"58b754fc.b65434","type":"debug","z":"635b69bb.594868","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":200,"wires":[]}]

Vaughan, maybe you did this already. Then were are not much wiser. If not, please try this as in my test flow.

If you set the inject to send ID\r as a string then it will send exactly those characters... it does NOT escape the the \r to be a carriage return (or Enter key). If you set it to use JSON input then you can set it to "ID\r" and that does then escape the \r .

An alternative is to use a function node after the inject to do msg.payload = msg.payload + "\r"; to then add it to any thing you inject.

Ok setting the inject node to JSON and with "ID\r" this worked.

Got the following response from device.

Thanks for everyone's input so far, I guess now I need to Convert this ASCII code to payload then send on to MQTT.

Any tips on the code I should use in the Function node to convert this ASCII code?

Node-red-contrib-buffer-parser can help you converting the bytes back to meaningful values.

Ok thanks any tip on how I can set the node up , Where do I start with this one?

Firstly, copy the buffer (use the "copy value" button that appears under your mouse when you hover over it)

then you paste that into an inject node set for buffer - so you can re-create the message any time you want.

Then using the manual for what the returned data means, add entries into the buffer parser as per the manual & test it by pressing the inject.

Ok ? isn't these values meant to be converted to ASCII to Normal Values?


I need to create something that can covert any ASCIi data strings right?


yes, however, what use is that? You should be making a useable formatted object, something like

  "id": "INWMPblahblahblah",
  "ip": "",
  "version": "0.0.1",
  "value": -44

my point was, parse your response. - so capture a message & put it in an inject & you can inject & test & design until it looks correct / useful.

The buffer parser (or a function node if you want) can help you achieve this - but you will need to interpret the manual to understand the response.

Can you give me an example of how I want set up the buffer parser node, I cant get my head around this.

I had a break through and was able to get things to this point,

Would you recommend this setup for reading values from the device?

Are you using the fixed settings for the buffer parser? For example, If the buffer length changes, it will truncate your string or give you an error. You may want to consider setting the parameters in a message to the buffer parser. That is covered some in the help documentation in the buffer maker or buffer parser help. You would simply use a function node to modify the configuration in the message, as you send the message containing your payload buffer-parser value.

Yes it was configured as fix setting I will have a read about this.
Can you give me an example of a function node set to do this?

the best means for this is to read the documentation in the Help.

But first send your buffer to the node and then output the message to a Full Message debug node. Not the default, but change it to show the complete message in there you will find the "specification". you need an object similar to that but in the "spec". That is in the help. Create that information in your spec object and send it to the node.

I hope that gets you started. I can resume the discussion later tonight or tomorrow. Gotta run.