After some research I was able to get receive the data over serial, split it and shift the bits into separate variables to publish over MQTT. Using the Paho MQTT python library it is trivial to connect and publish. I decided to map out it out as JeeNode/node#/name/value. Simple. I should mention this code is assuming the JeeNode is running the room node sketch or at least using the packet format. My remote nodes and receive node code is on Github if needed. Here is a graphical view of the tree for one node.
MQTT JeeNode Map |
This turned out much easier than I had anticipated. The last thing is to clean up the code and put in some error handling so it will resume if there is an error or reconnect if disconnected from the MQTT gateway. The one error I encountered was when the JeeNode would request an acknowledgment and the ACK crashes the python script since it is looking for an integer. This was easily solved by checking for digits after we read a line from the serial port and split the data. The final part is just updating the items in openHAB to point to the new MQTT path. For now the gateway is running from the command prompt under a screen session in the background. The code can be found on GitHub.
https://github.com/FriedCircuits/Home_Automation/tree/master/JeeNode-MQTT-Gateway
I hope someone finds this useful since I searched quite a bit and it seems no one else has published something like this, at least in what I could find. Minus the thermostat this screenshot shows the sensors that are using the gateway.
Sensor data from JeeNode MQTT Gateway |
No comments:
Post a Comment