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":"32089d81.1514d2","type":"mqtt-broker","z":"124898bd.f6036f","broker":"localhost","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"31e5b3b1.099454","type":"tcp in","z":"8eff0b7.93469f8","name":"X10 input","server":"client","host":"localhost","port":"1099","datamode":"stream","datatype":"buffer","newline":",","topic":"X10 input","base64":false,"x":188,"y":277,"wires":[["c986e94.6df4298"]]},{"id":"c986e94.6df4298","type":"function","z":"8eff0b7.93469f8","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].trim(); \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":235,"y":340,"wires":[["44c8ea8.929d394","a43155e6.4ff33"]]},{"id":"44c8ea8.929d394","type":"mqtt out","z":"8eff0b7.93469f8","name":"MQTT Out","topic":"X10Bridge/","qos":"","retain":"","broker":"32089d81.1514d2","x":563,"y":329,"wires":[]},{"id":"a43155e6.4ff33","type":"debug","z":"8eff0b7.93469f8","name":"test out","active":true,"console":"false","complete":"payload","x":561,"y":273.5,"wires":[]},{"id":"155410bc.5769cf","type":"comment","z":"8eff0b7.93469f8","name":"X10 to MQTT bridge","info":"","x":192,"y":235,"wires":[]}]

Flow Info

Created 9 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • comment (x1)
  • debug (x1)
  • function (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • tcp in (x1)

Tags

  • 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