X10 CM15A to MQTT bridge

Connects to a port where you have mochad installed to recieve X10 traffic. converts the hex data into string and then cleans it up to sends to MQTT. I don't have sending data figured out yet.

[{"id":"MQTT.Localhost","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"97d51a50.1542d8","type":"info","name":"Recieves data from X10 CM15A , converts and parses, then sends it to MQTT","info":"","icon":"commentdown.png","langs":[{"key":"en-US","title":"Recieves data from X10 CM15A , converts and parses, then sends it to MQTT","body":"","isDefault":true}],"currentLanguage":"en-US","x":315,"y":70,"z":"c3aed0d3.3ce58","wires":[]},{"id":"e89636af.ad1bd8","type":"tcp in","name":"X10 input","server":"client","host":"localhost","port":"1099","datamode":"stream","datatype":"buffer","newline":",","topic":"X10 input","base64":false,"x":94,"y":117,"z":"c3aed0d3.3ce58","wires":[["d0932c81.1ac68"]]},{"id":"16019a35.74ed96","type":"display","active":true,"x":523,"y":175,"z":"c3aed0d3.3ce58","wires":[]},{"id":"d0932c81.1ac68","type":"function","name":"Convert Hex to String","func":"var hexInput, stringInput, houseUnit, func, i, outString, strArray;          // declare variables\nhexInput = msg.payload;                                 // read the input into a variable called hexInput\nconst buf2 = new Buffer(hexInput, 'hex');               // use the \"Buffer\" function and identifies the encoding as hex \nstringInput = buf2.toString();                          // convert our hex buffer to a string       \nif (stringInput.length > 100){                           // if the string length is over 60 we parse it (there are sometimes shorter messages that we want to skip)     \n    strArray = stringInput.split(\" \");\n    i = strArray.indexOf(\"HouseUnit:\") + 1;\n    houseUnit = \"HouseUnit: \" + strArray[i];               // take the second value in the array and add \"House:\" back to the beginning of it\n    //i = strArray.indexOf(\"Func:\") + 1;\n    //func = \"Func: \" + strArray[i]; \n    i = strArray.length - 1;\n    func = \"Func: \" + strArray[i]; \n    outString = houseUnit + \" \" + func;                 // take the second value in the array and add \"House:\" back to the beginning of it\n    return {payload: outString};                        // return our new cleaned value to the output of the funtion\n}\n\n\n\n","outputs":1,"noerr":0,"x":306,"y":118,"z":"c3aed0d3.3ce58","wires":[["16019a35.74ed96","294d95e2.15ee32"]]},{"id":"294d95e2.15ee32","type":"mqtt out","name":"MQTT Out","topic":"X10_Messages_01/","qos":"0","retain":"false","broker":"MQTT.Localhost","x":530,"y":112,"z":"c3aed0d3.3ce58","wires":[]}]

Flow Info

created 2 years, 4 months ago

Node Types

  • function (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • tcp in (x1)
  • display (x1)
  • info (x1)


  • x10
  • CM15A
  • MQTT
  • Bridge
  • port
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option