openHAB and MQTT

Today has been a bit of a major step forward as far as integrating the various components go with the Home Automation and Power Management System or HAPMaS.

MQTT is a way to send short messages between components. It is lightweight, quick, efficient. What’s more, it is a centralised messaging system that is independent from any other components.

The way it works is pretty simple…

You run a MQTT Broker program on any of the servers/PCs. There are a few MQTT Brokers around but I have chosen the free, Open Source one called Mosquitto.

So, Mosquitto runs on a computer somewhere. Other components can publish messages to the Broker or subscribe to messages at the Broker.

When a device publishes a message with a particular id the message is lodged at the Broker and it then sends out the message to all the devices that have subscribed to that message id. Messages are identified with a simple string of text such as myhouse/garagedoor.

This means that any device that can use MQTT can post data to the Broker and any device interested in a particular message can subscribe and always get the latest values.

It is a simple system that allows small discrete bits of information, such as a temperature, a state of a door etc, to be easily disseminated to any other device that is interested or to a central system such as openHAB.

I installed Mosquitto on the same Linux server that openHAB is running and set up a Item in openHAB to display the value of a MQTT message. It uses the openHAB MQTT Binding. It all works superbly and will allow me to start to finally piece together a framework for HAPMaS.

Tomorrow I hope to finally build a temperature/humidity module and to link it in to HAPMaS and openHAB.


One thought on “openHAB and MQTT”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.