This project bridges the gap between X10 based devices andnewer SmartHome IoT devices that rely on mqtt. X10 hasa signifacant install base and the cost to convert a completeX10 install to modern IoT devices is cost prohibitive. This libaryallows X10 device to respond to mqtt messages and blend seemlesslyinto a modern IoT network. A psudeo state of the device is storedso the device state can be queried.
A key part of the config.json file maps mqtt topics to devices. Thistell mqtt-x10-bridge which topics to subscribe to and when a messageis recieved what x10 device to turn on/off.
.. "topics":{"house/livingroom/lamp/command":{ "house":"G", "module":"2", "status":"house/livingroom/lamp/status" }, . .
For each device an entry into topics to added. The statusentry is the queue to publish current status to. The currentstatus is stored so it can be queried like modern IoT devices.
The bridge depends on the node-x10-comm module to send the commandsto the serial port and the serialport module to interface with theserial port itself.
The message body is a simple 0 or 1 for on or off. An example ofpublishing a message to turn off the device using mosquitto_pub client:
mosquitto_pub -h 127.0.0.1 -t house/outside/landscaping/command -m 0
The configuration entries that must be updated include:
- mqttServerUrl - url of the mqtt server to connect to. This can either startwith tcp:// or mqtts://. If it starts with mqtts:// there must be a subdirectoryin the lib directory called mqttclient which contains ca.cert, client.cert,client.key which contain the key and associated certificates for a clientwhich is authorized to connect to the mqtt server.
- serialPort - the serial port that should be used to send out the commands
- topics - a mapping of topics to deviceshouse: X10 house codemodule: X10 module numberstatus: mqtt topic to publish current device status
Clone this repository and then run npm install.
Make sure you have installed both gcc-4.8 and g++-4.8 and they are the default compilersas native compiles are required for the serialport module.
To run the mqtt-x10-bridge app, add node.js to your path (currently requires 4.x or better) andthen run:
npm start