Closed ghost closed 6 years ago
Looking at the RFLink API documentation the protocol at the serial port level is completely different. However, as it uses a text format instead of binary, it should be possible to control it from node-red using a serialport node, maybe with a couple of function nodes to convert payload and topic to the right command string. You also need to set the baud rate to 57600 which is different from the RFXtrx433.
Thank you Max for your quick reply! I already did that in node-red and as you said using the right serialport values its giving me debug-output like "20;99;LaCrosse;ID=0400;HUM=76;" for my old 433 weather-station. When using the "switch-node" i can seperate the incoming payloads via IDs into topics, but how can i for example convert the "20;99;LaCrosse;ID=0400;HUM=76;" payload to extract only the actual "76" value? Also the incoming temperature payload (20;9A;LaCrosse;ID=0400;TEMP=0001;) is hexadecimal, so what could be a function to translate that into decimal payload ? Thanks for your help
This type of thing is simplest to do in a function node. Here is an example flow where I use inject nodes to send the messages you quoted, and a function node to split them apart.
The Javascript split()
method (of the String
class) takes the string to which it applies, and breaks it apart into sections delimited by the ';' character passed as a parameter. It creates an Array of strings, e.g. ['20', '99', 'LaCrosse', 'ID=0400', 'HUM=76']
. The array indexes start at 0, so parts[4]
contains the actual reading. I use split()
again, this time splitting on the '=' character. I test whether the name part data[0]
is 'HUM' or 'TEMP' and process the value part appropriately. The second argument to parseInt()
tells it what base to use, in this case 16 for hexadecimal. This function parses an integer from a string, but like all Javascript numbers, its return value is a floating-point number. You can multiply this by an appropriate scaling factor, if required. Finally assign the result to msg.payload
and return:
[ { "id": "3bc1edc.98c7592", "type": "inject", "z": "e09a97d6.a30b6", "name": "LaCrosse humidity", "topic": "RFlink", "payload": "20;99;LaCrosse;ID=0400;HUM=76", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "x": 136.5, "y": 57, "wires": [ [ "2f76b1fa.f12b06", "34c2a160.1fa65e" ] ] }, { "id": "2f76b1fa.f12b06", "type": "debug", "z": "e09a97d6.a30b6", "name": "", "active": true, "console": "false", "complete": "true", "x": 403.5, "y": 86, "wires": [] }, { "id": "34c2a160.1fa65e", "type": "function", "z": "e09a97d6.a30b6", "name": "Message splitting", "func": "var parts, data;\nparts = msg.payload.split(\";\");\ndata = parts[4].split(\"=\");\nif (data[0] === 'HUM') {\n msg.payload = data[1];\n} else if (data[0] === 'TEMP') {\n msg.payload = parseInt(data[1], 16);\n}\nreturn msg;", "outputs": 1, "noerr": 0, "x": 298.5, "y": 180, "wires": [ [ "2f76b1fa.f12b06" ] ] }, { "id": "f6e721b7.9ebcc", "type": "inject", "z": "e09a97d6.a30b6", "name": "LaCrosse temperature", "topic": "RFlink", "payload": "20;99;LaCrosse;ID=0400;TEMP=001a", "payloadType": "str", "repeat": "", "crontab": "", "once": false, "x": 147, "y": 270, "wires": [ [ "34c2a160.1fa65e" ] ] } ]
Now that https://flows.nodered.org/node/node-red-contrib-rflink is published, I'll close this issue.
Hello Maxwell,
any chance of making a RFLINK node or adapt your excisting one to as i heard that both protocols are quite similiar ?
http://www.nemcon.nl/blog2/
You can build yourself a gateway for only about 10 dollars with Arduino Mega and there are a lot of 433 devices supported.... I already tried it with your node-red-contrib-rfxcom node modules but except of showing me a green light when connecting to the serial port, its giving me errors.